Skip to content
This repository was archived by the owner on Jun 6, 2019. It is now read-only.

Commit bd26fad

Browse files
committed
Merge pull request #3 from azakus/fix-base-path
Fix base path
2 parents a9bee25 + 6c17b0f commit bd26fad

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

url.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@
184184
if (EOF == c) {
185185
this._host = base._host;
186186
this._port = base._port;
187-
this._path = base._path;
187+
this._path = base._path.slice();
188188
this._query = base._query;
189189
break loop;
190190
} else if ('/' == c || '\\' == c) {
@@ -194,13 +194,13 @@
194194
} else if ('?' == c) {
195195
this._host = base._host;
196196
this._port = base._port;
197-
this._path = base._path;
197+
this._path = base._path.slice();
198198
this._query = '?';
199199
state = 'query';
200200
} else if ('#' == c) {
201201
this._host = base._host;
202202
this._port = base._port;
203-
this._path = base._path;
203+
this._path = base._path.slice();
204204
this._query = base._query;
205205
this._fragment = '#';
206206
state = 'fragment';
@@ -213,7 +213,7 @@
213213
(EOF != nextNextC && '/' != nextNextC && '\\' != nextNextC && '?' != nextNextC && '#' != nextNextC)) {
214214
this._host = base._host;
215215
this._port = base._port;
216-
this._path = base._path;
216+
this._path = base._path.slice();
217217
this._path.pop();
218218
}
219219
state = 'relative path';

urltestharness.html

+8
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,16 @@
55
<script src=testharness.js></script>
66
<script src=testharnessreport.js></script>
77
<script src=urltestparser.js></script>
8+
<script>forceJURL = true;</script>
9+
<script src="url.js"></script>
810
<div id=log></div>
911
<script>
12+
test(function() {
13+
var u = new URL('http://a/foo');
14+
var u2 = new URL('bar', u);
15+
assert_equals(u.href, 'http://a/foo');
16+
}, 'Consistency Check');
17+
1018
var setup = async_test("Loading data…")
1119
setup.step(function() {
1220
var request = new XMLHttpRequest()

0 commit comments

Comments
 (0)