File tree 3 files changed +393
-10
lines changed
3 files changed +393
-10
lines changed Original file line number Diff line number Diff line change @@ -1108,12 +1108,14 @@ namespace url {
1108
1108
state = kFileHost ;
1109
1109
} else {
1110
1110
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
+ }
1117
1119
}
1118
1120
state = kPath ;
1119
1121
continue ;
@@ -1196,6 +1198,14 @@ namespace url {
1196
1198
url->path .push_back (segment);
1197
1199
}
1198
1200
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
+ }
1199
1209
if (ch == ' ?' ) {
1200
1210
url->flags |= URL_FLAGS_HAS_QUERY;
1201
1211
state = kQuery ;
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
/* 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
5
5
License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html
6
6
*/
7
7
module . exports =
@@ -1620,6 +1620,33 @@ module.exports =
1620
1620
"href" : "sc://example.net/%23" ,
1621
1621
"pathname" : "/%23"
1622
1622
}
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
+ }
1623
1650
}
1624
1651
] ,
1625
1652
"search" : [
You can’t perform that action at this time.
0 commit comments