diff options
| author | Vojta Jina | 2011-11-04 17:15:03 -0700 | 
|---|---|---|
| committer | Igor Minar | 2011-11-30 11:17:25 -0500 | 
| commit | b9707d910e8dd354a2f684588c1e7d83c5f88b8a (patch) | |
| tree | 2c6d1d375bad6785c16c1e4c00b60ad826c2c888 | |
| parent | 5bbd64ac65a89f43ce30a948fc0e0f5442cacb1e (diff) | |
| download | angular.js-b9707d910e8dd354a2f684588c1e7d83c5f88b8a.tar.bz2 | |
style(): get rid off some jsl warnings
| -rw-r--r-- | src/service/http.js | 14 | ||||
| -rw-r--r-- | src/service/location.js | 14 | ||||
| -rw-r--r-- | src/widgets.js | 6 | ||||
| -rw-r--r-- | test/angular-mocksSpec.js | 4 | ||||
| -rw-r--r-- | test/service/httpSpec.js | 34 | 
5 files changed, 38 insertions, 34 deletions
| diff --git a/src/service/http.js b/src/service/http.js index d7ad9dde..049dbd50 100644 --- a/src/service/http.js +++ b/src/service/http.js @@ -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()); diff --git a/src/service/location.js b/src/service/location.js index f5928eb2..00e9c054 100644 --- a/src/service/location.js +++ b/src/service/location.js @@ -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 + '" !';      } diff --git a/src/widgets.js b/src/widgets.js index 227ab167..861e61bf 100644 --- a/src/widgets.js +++ b/src/widgets.js @@ -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){ diff --git a/test/angular-mocksSpec.js b/test/angular-mocksSpec.js index e117c26d..30814985 100644 --- a/test/angular-mocksSpec.js +++ b/test/angular-mocksSpec.js @@ -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');        }); diff --git a/test/service/httpSpec.js b/test/service/httpSpec.js index a235426e..83a6e860 100644 --- a/test/service/httpSpec.js +++ b/test/service/httpSpec.js @@ -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(); | 
