mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-19 15:32:31 +00:00
LibURL+LibWeb: Remove leading slash when converting url to path
...on Windows
This commit is contained in:
parent
5ff32fb090
commit
32ddeb82d6
Notes:
github-actions[bot]
2025-04-11 01:05:22 +00:00
Author: https://github.com/stasoid
Commit: 32ddeb82d6
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 ✅
5 changed files with 18 additions and 5 deletions
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue