From a27198d52e61adb9cedde04e51bbec74e66089da Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Mon, 18 Oct 2010 20:35:31 +0100 Subject: 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 --- src/services.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/services.js b/src/services.js index a8004dd1..70d774a9 100644 --- a/src/services.js +++ b/src/services.js @@ -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] || ''; -- cgit v1.2.3