mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-25 02:40:24 +00:00
fix incorect parsing of url if it contains dash - character
This commit is contained in:
parent
271b535c82
commit
4b9b9e9830
3 changed files with 13 additions and 4 deletions
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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){
|
||||
|
|
|
|||
|
|
@ -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(){
|
|||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue