diff options
| author | Misko Hevery | 2010-05-13 12:03:10 -0700 | 
|---|---|---|
| committer | Misko Hevery | 2010-05-13 12:03:10 -0700 | 
| commit | 4b9b9e98300b9554faf0c960674eb75750227404 (patch) | |
| tree | 9ed8ef7e8b499178dcce5e0133546c7dbea3dd3f | |
| parent | 271b535c8285cb90781bf1e8ee56d6e68210a6a9 (diff) | |
| download | angular.js-4b9b9e98300b9554faf0c960674eb75750227404.tar.bz2 | |
fix incorect parsing of url if it contains dash - character
| -rw-r--r-- | example/temp.html | 5 | ||||
| -rw-r--r-- | src/services.js | 2 | ||||
| -rw-r--r-- | test/servicesSpec.js | 10 | 
3 files changed, 13 insertions, 4 deletions
| diff --git a/example/temp.html b/example/temp.html index d6414417..31ef7aa6 100644 --- a/example/temp.html +++ b/example/temp.html @@ -4,6 +4,9 @@      <script type="text/javascript" src="../src/angular-bootstrap.js#autobind"></script>    </head>    <body> -    <a href="#" ng-click="$window.location.hash='123'"> {{'first'}}<br/>{{'second'}}</a> +    {{$location.hashSearch.order}} <br/> +  	<input type="radio" name="$location.hashSearch.order" value="Report"/> Report <br/> +  	<input type="radio" name="$location.hashSearch.order" value="Problem"/> Problem <br/> +    {{$location.hashSearch.order}} <br/>    </body>  </html> diff --git a/src/services.js b/src/services.js index bdfbfdb4..55e3b2f6 100644 --- a/src/services.js +++ b/src/services.js @@ -3,7 +3,7 @@ angularService("$document", function(window){    return jqLite(window.document);  }, {inject:['$window']}); -var URL_MATCH = /^(file|ftp|http|https):\/\/(\w+:{0,1}\w*@)?([\w\.]*)(:([0-9]+))?([^\?#]+)(\?([^#]*))?(#(.*))?$/; +var URL_MATCH = /^(file|ftp|http|https):\/\/(\w+:{0,1}\w*@)?([\w\.-]*)(:([0-9]+))?([^\?#]+)(\?([^#]*))?(#(.*))?$/;  var HASH_MATCH = /^([^\?]*)?(\?([^\?]*))?$/;  var DEFAULT_PORTS = {'http': 80, 'https': 443, 'ftp':21};  angularService("$location", function(browser){ diff --git a/test/servicesSpec.js b/test/servicesSpec.js index de2d2b2b..17f71bdc 100644 --- a/test/servicesSpec.js +++ b/test/servicesSpec.js @@ -88,6 +88,14 @@ describe("service", function(){        expect(log).toEqual('/abc;');      }); +    it("should parse url which contains - in host", function(){ +      scope.$location.parse('http://a-b1.c-d.09/path'); +      expect(scope.$location.href).toEqual('http://a-b1.c-d.09/path'); +      expect(scope.$location.protocol).toEqual('http'); +      expect(scope.$location.host).toEqual('a-b1.c-d.09'); +      expect(scope.$location.path).toEqual('/path'); +    }); +    });    describe("$invalidWidgets", function(){ @@ -255,5 +263,3 @@ describe("service", function(){  }); - - | 
