mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
style(): get rid off some jsl warnings
This commit is contained in:
parent
5bbd64ac65
commit
b9707d910e
5 changed files with 38 additions and 34 deletions
|
|
@ -61,13 +61,17 @@ function transform(data, fns, param) {
|
|||
* @description
|
||||
*/
|
||||
function $HttpProvider() {
|
||||
var JSON_START = /^\s*[\[\{]/,
|
||||
JSON_END = /[\}\]]\s*$/,
|
||||
PROTECTION_PREFIX = /^\)\]\}',?\n/;
|
||||
|
||||
var $config = this.defaults = {
|
||||
// transform in-coming reponse data
|
||||
transformResponse: function(data) {
|
||||
if (isString(data)) {
|
||||
// strip json vulnerability protection prefix
|
||||
data = data.replace(/^\)\]\}',?\n/, '');
|
||||
if (/^\s*[\[\{]/.test(data) && /[\}\]]\s*$/.test(data))
|
||||
data = data.replace(PROTECTION_PREFIX, '');
|
||||
if (JSON_START.test(data) && JSON_END.test(data))
|
||||
data = fromJson(data, true);
|
||||
}
|
||||
return data;
|
||||
|
|
@ -313,9 +317,9 @@ function $HttpProvider() {
|
|||
*/
|
||||
function headers(name) {
|
||||
if (name) {
|
||||
return parsedHeaders
|
||||
? parsedHeaders[lowercase(name)] || null
|
||||
: rawRequest.getResponseHeader(name);
|
||||
return parsedHeaders ?
|
||||
parsedHeaders[lowercase(name)] || null :
|
||||
rawRequest.getResponseHeader(name);
|
||||
}
|
||||
|
||||
parsedHeaders = parsedHeaders || parseHeaders(rawRequest.getAllResponseHeaders());
|
||||
|
|
|
|||
|
|
@ -25,12 +25,12 @@ function encodePath(path) {
|
|||
|
||||
|
||||
function matchUrl(url, obj) {
|
||||
var match = URL_MATCH.exec(url),
|
||||
var match = URL_MATCH.exec(url);
|
||||
|
||||
match = {
|
||||
protocol: match[1],
|
||||
host: match[3],
|
||||
port: parseInt(match[5]) || DEFAULT_PORTS[match[1]] || null,
|
||||
port: parseInt(match[5], 10) || DEFAULT_PORTS[match[1]] || null,
|
||||
path: match[6] || '/',
|
||||
search: match[8],
|
||||
hash: match[10]
|
||||
|
|
@ -61,7 +61,7 @@ function convertToHtml5Url(url, basePath, hashPrefix) {
|
|||
|
||||
// already html5 url
|
||||
if (decodeURIComponent(match.path) != basePath || isUndefined(match.hash) ||
|
||||
match.hash.indexOf(hashPrefix) != 0) {
|
||||
match.hash.indexOf(hashPrefix) !== 0) {
|
||||
return url;
|
||||
// convert hashbang url -> html5 url
|
||||
} else {
|
||||
|
|
@ -84,7 +84,7 @@ function convertToHashbangUrl(url, basePath, hashPrefix) {
|
|||
pathPrefix = pathPrefixFromBase(basePath),
|
||||
path = match.path.substr(pathPrefix.length);
|
||||
|
||||
if (match.path.indexOf(pathPrefix) != 0) {
|
||||
if (match.path.indexOf(pathPrefix) !== 0) {
|
||||
throw 'Invalid url "' + url + '", missing path prefix "' + pathPrefix + '" !';
|
||||
}
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ function LocationUrl(url, pathPrefix) {
|
|||
this.$$parse = function(url) {
|
||||
var match = matchUrl(url, this);
|
||||
|
||||
if (match.path.indexOf(pathPrefix) != 0) {
|
||||
if (match.path.indexOf(pathPrefix) !== 0) {
|
||||
throw 'Invalid url "' + url + '", missing path prefix "' + pathPrefix + '" !';
|
||||
}
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ function LocationUrl(url, pathPrefix) {
|
|||
this.$$hash = match.hash && decodeURIComponent(match.hash) || '';
|
||||
|
||||
this.$$compose();
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Compose url and update `absUrl` property
|
||||
|
|
@ -160,7 +160,7 @@ function LocationHashbangUrl(url, hashPrefix) {
|
|||
this.$$parse = function(url) {
|
||||
var match = matchUrl(url, this);
|
||||
|
||||
if (match.hash && match.hash.indexOf(hashPrefix) != 0) {
|
||||
if (match.hash && match.hash.indexOf(hashPrefix) !== 0) {
|
||||
throw 'Invalid url "' + url + '", missing hash prefix "' + hashPrefix + '" !';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -434,9 +434,9 @@ angularWidget('@ng:repeat', function(expression, element){
|
|||
childScope[valueIdent] = value;
|
||||
if (keyIdent) childScope[keyIdent] = key;
|
||||
childScope.$index = index;
|
||||
childScope.$position = index == 0
|
||||
? 'first'
|
||||
: (index == collectionLength - 1 ? 'last' : 'middle');
|
||||
childScope.$position = index === 0 ?
|
||||
'first' :
|
||||
(index == collectionLength - 1 ? 'last' : 'middle');
|
||||
|
||||
if (!last) {
|
||||
linker(childScope, function(clone){
|
||||
|
|
|
|||
4
test/angular-mocksSpec.js
vendored
4
test/angular-mocksSpec.js
vendored
|
|
@ -697,8 +697,8 @@ describe('mocks', function() {
|
|||
|
||||
hb('POST', '/u1', 'ddd', noop, {});
|
||||
|
||||
expect(function() {hb.verifyNoOutstandingExpectation();})
|
||||
.toThrow('Unsatisfied requests: GET /u2, POST /u3');
|
||||
expect(function() {hb.verifyNoOutstandingExpectation();}).
|
||||
toThrow('Unsatisfied requests: GET /u2, POST /u3');
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -61,9 +61,9 @@ describe('$http', function() {
|
|||
|
||||
it('should log more exceptions', function() {
|
||||
$httpBackend.expect('GET', '/url').respond(500, '');
|
||||
$http({url: '/url', method: 'GET'})
|
||||
.on('500', throwing('exception in error callback'))
|
||||
.on('5xx', throwing('exception in error callback'));
|
||||
$http({url: '/url', method: 'GET'}).
|
||||
on('500', throwing('exception in error callback')).
|
||||
on('5xx', throwing('exception in error callback'));
|
||||
$httpBackend.flush();
|
||||
|
||||
expect($exceptionHandler.errors.length).toBe(2);
|
||||
|
|
@ -491,7 +491,7 @@ describe('$http', function() {
|
|||
|
||||
beforeEach(function() {
|
||||
$httpBackend.when('GET').respond(function(m, url) {
|
||||
return [parseInt(url.substr(1)), '', {}];
|
||||
return [parseInt(url.substr(1), 10), '', {}];
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -550,13 +550,13 @@ describe('$http', function() {
|
|||
|
||||
it('should call all matched callbacks', function() {
|
||||
var no = jasmine.createSpy('wrong');
|
||||
$http({method: 'GET', url: '/205'})
|
||||
.on('xxx', callback)
|
||||
.on('2xx', callback)
|
||||
.on('205', callback)
|
||||
.on('3xx', no)
|
||||
.on('2x1', no)
|
||||
.on('4xx', no);
|
||||
$http({method: 'GET', url: '/205'}).
|
||||
on('xxx', callback).
|
||||
on('2xx', callback).
|
||||
on('205', callback).
|
||||
on('3xx', no).
|
||||
on('2x1', no).
|
||||
on('4xx', no);
|
||||
|
||||
$httpBackend.flush();
|
||||
|
||||
|
|
@ -576,10 +576,10 @@ describe('$http', function() {
|
|||
it('should preserve the order of listeners', function() {
|
||||
var log = '';
|
||||
|
||||
$http({method: 'GET', url: '/201'})
|
||||
.on('2xx', function() {log += '1';})
|
||||
.on('201', function() {log += '2';})
|
||||
.on('2xx', function() {log += '3';});
|
||||
$http({method: 'GET', url: '/201'}).
|
||||
on('2xx', function() {log += '1';}).
|
||||
on('201', function() {log += '2';}).
|
||||
on('2xx', function() {log += '3';});
|
||||
|
||||
$httpBackend.flush();
|
||||
expect(log).toBe('123');
|
||||
|
|
@ -766,8 +766,8 @@ describe('$http', function() {
|
|||
function second(d) {return d + '2';}
|
||||
|
||||
$httpBackend.expect('POST', '/url').respond('0');
|
||||
$http({method: 'POST', url: '/url', transformResponse: [first, second]})
|
||||
.on('200', callback);
|
||||
$http({method: 'POST', url: '/url', transformResponse: [first, second]}).
|
||||
on('200', callback);
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(callback).toHaveBeenCalledOnce();
|
||||
|
|
|
|||
Loading…
Reference in a new issue