diff options
| author | ROUL | 2013-11-10 02:25:33 +0100 |
|---|---|---|
| committer | Jeff Cross | 2013-11-12 22:41:06 -0800 |
| commit | f925e8caa6c51a7d45ca9ead30601ec2e9d4464c (patch) | |
| tree | b8ad85284ed43fba1678ee89f086e4f722b323bf /test | |
| parent | e1254b266dfa2d4e3756e4317152dbdbcabe44be (diff) | |
| download | angular.js-f925e8caa6c51a7d45ca9ead30601ec2e9d4464c.tar.bz2 | |
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
Diffstat (limited to 'test')
| -rw-r--r-- | test/ng/locationSpec.js | 43 |
1 files changed, 43 insertions, 0 deletions
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/'); |
