From d0bdd2662590a436305355c1bf84754d756689b4 Mon Sep 17 00:00:00 2001 From: Mert Can Altin Date: Sun, 26 Oct 2025 20:17:32 +0300 Subject: [PATCH] accepting windows backslash paths --- url/resources/urltestdata.json | 453 +++++++++++++++++++++++++++++++++ 1 file changed, 453 insertions(+) diff --git a/url/resources/urltestdata.json b/url/resources/urltestdata.json index d1a06f6319d1bc..7fe062359858bb 100644 --- a/url/resources/urltestdata.json +++ b/url/resources/urltestdata.json @@ -10238,5 +10238,458 @@ "pathname": "/a\\b", "search": "", "hash": "" + }, + "# Windows backslash path tests - should be converted to forward slashes", + { + "input": "C:\\path\\file.node", + "base": "http://example.org/", + "href": "file:///C:/path/file.node", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/C:/path/file.node", + "search": "", + "hash": "" + }, + "# Non-ASCII and Unicode character tests", + { + "input": "C:\\résumé\\café.txt", + "base": null, + "href": "file:///C:/r%C3%A9sum%C3%A9/caf%C3%A9.txt", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/C:/r%C3%A9sum%C3%A9/caf%C3%A9.txt", + "search": "", + "hash": "" + }, + { + "input": "C:\\中文\\文档.txt", + "base": null, + "href": "file:///C:/%E4%B8%AD%E6%96%87/%E6%96%87%E6%A1%A3.txt", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/C:/%E4%B8%AD%E6%96%87/%E6%96%87%E6%A1%A3.txt", + "search": "", + "hash": "" + }, + { + "input": "C:\\Здравствуй\\мир.txt", + "base": null, + "href": "file:///C:/%D0%97%D0%B4%D1%80%D0%B0%D0%B2%D1%81%D1%82%D0%B2%D1%83%D0%B9/%D0%BC%D0%B8%D1%80.txt", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/C:/%D0%97%D0%B4%D1%80%D0%B0%D0%B2%D1%81%D1%82%D0%B2%D1%83%D0%B9/%D0%BC%D0%B8%D1%80.txt", + "search": "", + "hash": "" + }, + { + "input": "D:\\foo\\bar.exe", + "base": null, + "href": "file:///D:/foo/bar.exe", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/D:/foo/bar.exe", + "search": "", + "hash": "" + }, + "# UNC paths without base URL should fail (no special UNC handling)", + { + "input": "\\\\server\\share\\file.txt", + "base": null, + "failure": true, + "comment": "UNC paths are not specially handled; without a base they fail to parse" + }, + "# Mixed separators should be normalized", + { + "input": "C:\\path/mixed\\separators/file.txt", + "base": null, + "href": "file:///C:/path/mixed/separators/file.txt", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/C:/path/mixed/separators/file.txt", + "search": "", + "hash": "" + }, + "# Relative backslash paths with base URL", + { + "input": "..\\parent\\file.txt", + "base": "file:///C:/current/dir/", + "href": "file:///C:/current/parent/file.txt", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/C:/current/parent/file.txt", + "search": "", + "hash": "" + }, + "# Unicode characters in Windows paths", + { + "input": "C:\\Documents\\project.txt", + "base": null, + "href": "file:///C:/Documents/project.txt", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/C:/Documents/project.txt", + "search": "", + "hash": "" + }, + { + "input": "C:\\Music\\songs\\test.mp3", + "base": null, + "href": "file:///C:/Music/songs/test.mp3", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/C:/Music/songs/test.mp3", + "search": "", + "hash": "" + }, + "# Emoji in Windows paths", + { + "input": "C:\\📁Folder\\📄Document.txt", + "base": null, + "href": "file:///C:/%F0%9F%93%81Folder/%F0%9F%93%84Document.txt", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/C:/%F0%9F%93%81Folder/%F0%9F%93%84Document.txt", + "search": "", + "hash": "" + }, + "# Windows paths with query and fragment", + { + "input": "C:\\path\\file.html?query=value", + "base": null, + "href": "file:///C:/path/file.html?query=value", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/C:/path/file.html", + "search": "?query=value", + "hash": "" + }, + { + "input": "C:\\path\\file.html#section", + "base": null, + "href": "file:///C:/path/file.html#section", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/C:/path/file.html", + "search": "", + "hash": "#section" + }, + "# Edge cases and error conditions", + { + "input": "C:\\invalid\\path\\with\\\\double\\backslash", + "base": null, + "href": "file:///C:/invalid/path/with//double/backslash", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/C:/invalid/path/with//double/backslash", + "search": "", + "hash": "" + }, + { + "input": ":\\invalid\\drive", + "base": null, + "failure": true + }, + "# Network paths without base URL should fail (no special UNC handling)", + { + "input": "\\\\server.domain.com\\share\\folder\\file.txt", + "base": null, + "failure": true, + "comment": "UNC paths are not specially handled; without a base they fail to parse" + }, + "# Case sensitivity tests", + { + "input": "c:\\Windows\\System32\\file.dll", + "base": null, + "href": "file:///c:/Windows/System32/file.dll", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/c:/Windows/System32/file.dll", + "search": "", + "hash": "" + }, + { + "input": "C:\\folder{brace}\\file.txt", + "base": null, + "href": "file:///C:/folder%7Bbrace%7D/file.txt", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/C:/folder%7Bbrace%7D/file.txt", + "search": "", + "hash": "" + }, + { + "input": "C:\\folder`backtick`\\file.txt", + "base": null, + "href": "file:///C:/folder%60backtick%60/file.txt", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/C:/folder%60backtick%60/file.txt", + "search": "", + "hash": "" + }, + { + "input": "C:\\folder^caret\\file.txt", + "base": null, + "href": "file:///C:/folder%5Ecaret/file.txt", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/C:/folder%5Ecaret/file.txt", + "search": "", + "hash": "" + }, + "# Spaces and special formatting characters", + { + "input": "C:\\My Documents\\file with spaces.txt", + "base": null, + "href": "file:///C:/My%20Documents/file%20with%20spaces.txt", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/C:/My%20Documents/file%20with%20spaces.txt", + "search": "", + "hash": "" + }, + "# Multiple consecutive backslashes - various scenarios", + { + "input": "C:\\\\\\path\\file.txt", + "base": null, + "href": "file:///C:///path/file.txt", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/C:///path/file.txt", + "search": "", + "hash": "" + }, + { + "input": "C:\\path\\\\file.txt", + "base": null, + "href": "file:///C:/path//file.txt", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/C:/path//file.txt", + "search": "", + "hash": "" + }, + "# Non-Windows drive patterns (multi-letter or non-alpha) are parsed as normal URLs", + { + "input": "CC:\\path\\file.txt", + "base": "about:blank", + "href": "cc:\\path\\file.txt", + "protocol": "cc:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "\\path\\file.txt", + "search": "", + "hash": "" + }, + { + "input": "1:\\path\\file.txt", + "base": "about:blank", + "failure": true, + "comment": "Schemes must start with an ASCII letter, not a digit" + }, + { + "input": "@:\\path\\file.txt", + "base": "about:blank", + "failure": true, + "comment": "@ is not a valid scheme character" + }, + "# Drive letter edge cases", + { + "input": "Z:\\root\\file.txt", + "base": null, + "href": "file:///Z:/root/file.txt", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/Z:/root/file.txt", + "search": "", + "hash": "" + }, + { + "input": "a:\\lowercase\\file.txt", + "base": null, + "href": "file:///a:/lowercase/file.txt", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/a:/lowercase/file.txt", + "search": "", + "hash": "" + }, + "# Complex query and fragment scenarios", + { + "input": "C:\\path\\file.html?param=value&other=123", + "base": null, + "href": "file:///C:/path/file.html?param=value&other=123", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/C:/path/file.html", + "search": "?param=value&other=123", + "hash": "" + }, + { + "input": "C:\\path\\file.html#section1#section2", + "base": null, + "href": "file:///C:/path/file.html#section1#section2", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/C:/path/file.html", + "search": "", + "hash": "#section1#section2" + }, + { + "input": "C:\\path\\file.html?query=test#fragment", + "base": null, + "href": "file:///C:/path/file.html?query=test#fragment", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/C:/path/file.html", + "search": "?query=test", + "hash": "#fragment" + }, + "# Long path scenarios", + { + "input": "C:\\very\\long\\path\\with\\many\\nested\\directories\\and\\subdirectories\\file.txt", + "base": null, + "href": "file:///C:/very/long/path/with/many/nested/directories/and/subdirectories/file.txt", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/C:/very/long/path/with/many/nested/directories/and/subdirectories/file.txt", + "search": "", + "hash": "" + }, + "# Root directory access", + { + "input": "C:\\", + "base": null, + "href": "file:///C:/", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/C:/", + "search": "", + "hash": "" + }, + { + "input": "C:\\\\", + "base": null, + "href": "file:///C://", + "protocol": "file:", + "username": "", + "password": "", + "host": "", + "hostname": "", + "port": "", + "pathname": "/C://", + "search": "", + "hash": "" } ]