Explorar el Código

Auto merge of #412 - valenting:fix-file-bug, r=SimonSapin

Fix file:#frag test case

This test case used to be parsed as file:///frag\ and it would assert in check_invariants

Fixes #398

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-url/412)
<!-- Reviewable:end -->
bors-servo hace 9 años
padre
commit
e3e0b34a3b
Se han modificado 2 ficheros con 15 adiciones y 0 borrados
  1. 1 0
      src/parser.rs
  2. 14 0
      tests/urltestdata.json

+ 1 - 0
src/parser.rs

@@ -451,6 +451,7 @@ impl<'a> Parser<'a> {
                     let scheme_end = "file".len() as u32;
                     let path_start = "file://".len() as u32;
                     let fragment_start = "file:///".len() as u32;
+                    self.serialization.push('#');
                     self.parse_fragment(input_after_first_char);
                     Ok(Url {
                         serialization: self.serialization,

+ 14 - 0
tests/urltestdata.json

@@ -5414,6 +5414,20 @@
     "search": "?q=v",
     "hash": ""
   },
+  {
+    "input": "file:#frag",
+    "base": "about:blank",
+    "href": "file:///#frag",
+    "protocol": "file:",
+    "username": "",
+    "password": "",
+    "host": "",
+    "hostname": "",
+    "port": "",
+    "pathname": "/",
+    "search": "",
+    "hash": "#frag"
+  },
   "# IPv6 tests",
   {
     "input": "http://[1:0::]",