Re: [whatwg/url] Why is the host dropped if the path contains a Windows drive letter? (#302)

I have made a bunch of screenshots with browserstack (initially for #405) and transcribed from them the results that are relevant to this issue. The results may also be relevant to #515. 

The following applies only to file URLs. 

Observations:

- Firefox always sets the host to the empty string. 
- IE, Edge, Chrome and Safari prior to version 10 preserve the host, but with exceptions:
  - IE and Edge append the drive letter to the host, if one is present. I assume this is a bug. 
  - Chrome/Windows sets the host to the empty string if the path contains a drive letter. 
  - IE, Edge and Safari replace `localhost` with the empty string. 
- Safari versions 10 and up seem to drop the host from the base URL if the input is an absolute file path, but the exact behaviour is unclear to me. 

* * * 
Browser Tests:

<table>
<tr><th colspan=2><code>/..//localhost/pig</code> against <code>file://lion/</code></th></tr>
<tr><td> IE8+ and Edge  </td><td> <code>file://lion//localhost//pig</code> </td></tr>
<tr><td> Chrome/Windows </td><td> <code>file://lion//localhost//pig</code> </td></tr>
<tr><td> Chrome/Mac     </td><td> <code>file://lion//localhost//pig</code> </td></tr>
<tr><td> Safari 5 - 9   </td><td> <code>file://lion//localhost//pig</code> </td></tr>
<tr><td> Safari 10 - 13 </td><td> <code>file:////localhost//pig</code> </td></tr>
<tr><td> Firefox        </td><td> <code>file:////localhost//pig</code> </td></tr>
</table>

<table>
<tr><th colspan=2><code>file://localhost//a//../..//</code></th></tr>
<tr><td> IE8+ and Edge  </td><td> <code>file:///.//</code> </td></tr>
<tr><td> Chrome/Windows </td><td> <code>file://localhost///</code> </td></tr>
<tr><td> Chrome/Mac     </td><td> <code>file://localhost///</code> </td></tr>
<tr><td> Safari 5 - 9   </td><td> <code>file://///</code> </td></tr>
<tr><td> Safari 10 - 13 </td><td> <code>file://///</code> </td></tr>
<tr><td> Firefox        </td><td> <code>file://///</code> </td></tr>
</table>

<table>
<tr><th colspan=2><code>file://localhost////foo</code></th></tr>
<tr><td> IE8+ and Edge  </td><td> <code>file://foo</code> </td></tr>
<tr><td> Chrome/Windows </td><td> <code>file://localhost////foo</code> </td></tr>
<tr><td> Chrome/Mac     </td><td> <code>file://localhost////foo</code> </td></tr>
<tr><td> Safari 5 - 9   </td><td> <code>file://////foo</code> </td></tr>
<tr><td> Safari 10 - 13 </td><td> <code>file://////foo</code> </td></tr>
<tr><td> Firefox        </td><td> <code>file://////foo</code> </td></tr>
</table>

<table>
<tr><th colspan=2><code>file://somehost/C:/test</code></th></tr>
<tr><td> IE8+ and Edge  </td><td> <code>file://somehostc:/test</code> </td></tr>
<tr><td> Chrome/Windows </td><td> <code>file:///C:/test</code> </td></tr>
<tr><td> Chrome/Mac     </td><td> <code>file://somehost/C:/test</code> </td></tr>
<tr><td> Safari 5 - 9   </td><td> <code>file://somehost/C:/test</code> </td></tr>
<tr><td> Safari 10 - 13 </td><td> <code>file://somehost/C:/test</code> </td></tr>
<tr><td> Firefox        </td><td> <code>file:///C:/test</code> </td></tr>
</table>

<table>
<tr><th colspan=2><code>file://host2/</code></th></tr>
<tr><td> IE8+ and Edge  </td><td> <code>file://host2/</code> </td></tr>
<tr><td> Chrome/Windows </td><td> <code>file://host2/</code> </td></tr>
<tr><td> Chrome/Mac     </td><td> <code>file://host2/</code> </td></tr>
<tr><td> Safari 5 - 9   </td><td> <code>file://host2/</code> </td></tr>
<tr><td> Safari 10 - 13 </td><td> <code>file://host2/</code> </td></tr>
<tr><td> Firefox        </td><td> <code>file:///</code> </td></tr>
</table>

<table>
<tr><th colspan=2><code>file:file2</code> against <code>file://host/D:/dir1/file1</code></th></tr>
<tr><td> IE8+ and Edge  </td><td> <code>file://hostd:/dir1/file2</code> </td></tr>
<tr><td> Chrome/Windows </td><td> <code>file:///D:/dir1/file2</code> </td></tr>
<tr><td> Chrome/Mac     </td><td> <code>file://host/D:/dir1/file2</code> </td></tr>
<tr><td> Safari 5 - 9   </td><td> <code>file://host/D:/dir1/file2</code> </td></tr>
<tr><td> Safari 10 - 13 </td><td> <code>file://host/D:/dir1/file2</code> </td></tr>
<tr><td> Firefox        </td><td> <code>file:///D:/dir1/file2</code> </td></tr>
</table>

<table>
<tr><th colspan=2><code>file:/file2</code> against <code>file://host/D:/dir1/file1</code></th></tr>
<tr><td> IE8+ and Edge  </td><td> <code>file://hostd:/file2</code> </td></tr>
<tr><td> Chrome/Windows </td><td> <code>file:///D:/file2</code> </td></tr>
<tr><td> Chrome/Mac     </td><td> <code>file://host/file2</code> </td></tr>
<tr><td> Safari 5 - 9   </td><td> <code>file:///file2</code> </td></tr>
<tr><td> Safari 10 - 13 </td><td> <code>file:///D:/file2</code> </td></tr>
<tr><td> Firefox        </td><td> <code>file:///file2</code> </td></tr>
</table>

<table>
<tr><th colspan=2><code>file:c:/dir2/</code> against <code>file://host/D:/dir1/file1</code></th></tr>
<tr><td> IE8+ and Edge  </td><td> <code>file://hostd:/c:/dir2/</code> </td></tr>
<tr><td> Chrome/Windows </td><td> <code>file:///C:/dir2/</code> </td></tr>
<tr><td> Chrome/Mac     </td><td> <code>file://host/D:/dir1/c:/dir</code> </td></tr>
<tr><td> Safari 5 - 9   </td><td> <code>file://host/D:/dir1/c:/dir</code> </td></tr>
<tr><td> Safari 10 - 13 </td><td> <code>file:///c:/dir2/</code> </td></tr>
<tr><td> Firefox        </td><td> <code>file:///D:/dir1/c:/dir2</code> </td></tr>
</table>

- IE6 and 7 are hard to test as they do not implement the `URL` constructor, and the `href` property on anchor elements only returns a parsed result in specific cases. So this remains to be investigated. 
- IE8+ and Edge results are from IE 8, 9, 10 and 11 and Edge 15, 16, 17, and 18. 
- Firefox results are from version 62 and 76 on Mac and from version 47 on Windows, but they all agree. (Others timed out on browserstack). 
- Chrome/Windows results are from versions 49 and 71, they all agree. 
- Chrome/Mac results are from version 71.


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/issues/302#issuecomment-628593739

Received on Thursday, 14 May 2020 12:14:44 UTC