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