mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibURL+LibWeb: Remove leading slash when converting url to path
...on Windows
This commit is contained in:
Notes:
github-actions[bot]
2025-04-11 01:05:22 +00:00
Author: https://github.com/stasoid Commit: https://github.com/LadybirdBrowser/ladybird/commit/32ddeb82d6a Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3569 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/R-Goc Reviewed-by: https://github.com/shannonbooth ✅
@@ -246,6 +246,18 @@ String URL::serialize_path() const
|
||||
return output.to_string_without_validation();
|
||||
}
|
||||
|
||||
// This function is used whenever a path is needed to access the actual file on disk.
|
||||
// On Windows serialize_path can produce a path like /C:/path/to/tst.htm, so the leading slash needs to be removed to obtain a valid path.
|
||||
ByteString URL::file_path() const
|
||||
{
|
||||
ByteString path = percent_decode(serialize_path());
|
||||
#ifdef AK_OS_WINDOWS
|
||||
if (path.starts_with('/'))
|
||||
path = path.substring(1);
|
||||
#endif
|
||||
return path;
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#concept-url-serializer
|
||||
String URL::serialize(ExcludeFragment exclude_fragment) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user