File tree Expand file tree Collapse file tree 3 files changed +393
-10
lines changed Expand file tree Collapse file tree 3 files changed +393
-10
lines changed Original file line number Diff line number Diff line change @@ -1108,12 +1108,14 @@ namespace url {
11081108 state = kFileHost ;
11091109 } else {
11101110 if (has_base &&
1111- base->scheme == " file:" &&
1112- base->flags & URL_FLAGS_HAS_PATH &&
1113- base->path .size () > 0 &&
1114- NORMALIZED_WINDOWS_DRIVE_LETTER (base->path [0 ])) {
1115- url->flags |= URL_FLAGS_HAS_PATH;
1116- url->path .push_back (base->path [0 ]);
1111+ base->scheme == " file:" ) {
1112+ if (NORMALIZED_WINDOWS_DRIVE_LETTER (base->path [0 ])) {
1113+ url->flags |= URL_FLAGS_HAS_PATH;
1114+ url->path .push_back (base->path [0 ]);
1115+ } else {
1116+ url->flags |= URL_FLAGS_HAS_HOST;
1117+ url->host = base->host ;
1118+ }
11171119 }
11181120 state = kPath ;
11191121 continue ;
@@ -1196,6 +1198,14 @@ namespace url {
11961198 url->path .push_back (segment);
11971199 }
11981200 buffer.clear ();
1201+ if (url->scheme == " file:" &&
1202+ (ch == kEOL ||
1203+ ch == ' ?' ||
1204+ ch == ' #' )) {
1205+ while (url->path .size () > 1 && url->path [0 ].length () == 0 ) {
1206+ url->path .erase (url->path .begin ());
1207+ }
1208+ }
11991209 if (ch == ' ?' ) {
12001210 url->flags |= URL_FLAGS_HAS_QUERY;
12011211 state = kQuery ;
Original file line number Diff line number Diff line change 11'use strict' ;
22
33/* WPT Refs:
4- https://github.com/w3c/web-platform-tests/blob/e48dd15 /url/setters_tests.json
4+ https://github.com/w3c/web-platform-tests/blob/3eff1bd /url/setters_tests.json
55 License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html
66*/
77module . exports =
@@ -1620,6 +1620,33 @@ module.exports =
16201620 "href" : "sc://example.net/%23" ,
16211621 "pathname" : "/%23"
16221622 }
1623+ } ,
1624+ {
1625+ "comment" : "File URLs and (back)slashes" ,
1626+ "href" : "file://monkey/" ,
1627+ "new_value" : "\\\\" ,
1628+ "expected" : {
1629+ "href" : "file://monkey/" ,
1630+ "pathname" : "/"
1631+ }
1632+ } ,
1633+ {
1634+ "comment" : "File URLs and (back)slashes" ,
1635+ "href" : "file:///unicorn" ,
1636+ "new_value" : "//\\/" ,
1637+ "expected" : {
1638+ "href" : "file:///" ,
1639+ "pathname" : "/"
1640+ }
1641+ } ,
1642+ {
1643+ "comment" : "File URLs and (back)slashes" ,
1644+ "href" : "file:///unicorn" ,
1645+ "new_value" : "//monkey/..//" ,
1646+ "expected" : {
1647+ "href" : "file:///" ,
1648+ "pathname" : "/"
1649+ }
16231650 }
16241651 ] ,
16251652 "search" : [
You can’t perform that action at this time.
0 commit comments