mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-22 10:49:24 +08:00
Added tests for URL_MATCH and fixed issue with empty path
This commit was produced by a combination of 4 commits:
- Added URL_MATCH test for basic url
- Moved two tests from $location to URL_MATCH, as they should be here
- Added test for host without "/" ending and fix the regexp to pass the test
- Added another test for matching empty abs path ("/") and fix the regexp
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
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]+))?(\/[^\?#]*)?(\?([^#]*))?(#(.*))?$/,
|
||||
HASH_MATCH = /^([^\?]*)?(\?([^\?]*))?$/,
|
||||
DEFAULT_PORTS = {'http': 80, 'https': 443, 'ftp':21},
|
||||
EAGER = 'eager',
|
||||
@@ -184,7 +184,7 @@ angularServiceInject("$location", function(browser) {
|
||||
loc.protocol = match[1];
|
||||
loc.host = match[3] || '';
|
||||
loc.port = match[5] || DEFAULT_PORTS[loc.protocol] || _null;
|
||||
loc.path = match[6];
|
||||
loc.path = match[6] || '';
|
||||
loc.search = parseKeyValue(match[8]);
|
||||
loc.hash = match[10] || '';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user