From f925e8caa6c51a7d45ca9ead30601ec2e9d4464c Mon Sep 17 00:00:00 2001 From: ROUL Date: Sun, 10 Nov 2013 02:25:33 +0100 Subject: fix(urlUtils): urlUtils doesn't return right path for file:// on win Chrome and other browsers on Windows often append the drive name to the pathname, as described in #4680. This would cause the location service to browse to odd URLs, such as /C:/myfile.html, when opening apps using file://. Fixes #4680 --- test/ng/locationSpec.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'test') diff --git a/test/ng/locationSpec.js b/test/ng/locationSpec.js index 30f2f81a..abd99585 100644 --- a/test/ng/locationSpec.js +++ b/test/ng/locationSpec.js @@ -10,6 +10,49 @@ describe('$location', function() { jqLite(document).off('click'); }); + + describe('File Protocol', function () { + var urlParsingNodePlaceholder; + + beforeEach(inject(function ($sniffer) { + if ($sniffer.msie) return; + + urlParsingNodePlaceholder = urlParsingNode; + + //temporarily overriding the DOM element + //with output from IE, if not in IE + urlParsingNode = { + hash : "#/C:/", + host : "", + hostname : "", + href : "file:///C:/base#!/C:/foo", + pathname : "/C:/foo", + port : "", + protocol : "file:", + search : "", + setAttribute: angular.noop + }; + })); + + + afterEach(inject(function ($sniffer) { + if ($sniffer.msie) return; + //reset urlParsingNode + urlParsingNode = urlParsingNodePlaceholder; + expect(urlParsingNode.pathname).not.toBe('/C:/foo'); + })); + + + it('should not include the drive name in path() on WIN', function (){ + //See issue #4680 for details + url = new LocationHashbangUrl('file:///base', '#!'); + url.$$parse('file:///base#!/foo?a=b&c#hash'); + + expect(url.path()).toBe('/foo'); + }); + }); + + describe('NewUrl', function() { beforeEach(function() { url = new LocationHtml5Url('http://www.domain.com:9877/'); -- cgit v1.2.3