mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 02:13:56 +09:00
AK: Port LexicalPath to Windows
Supported: * Normal absolute and relative paths: C:\Windows\Fonts, AK\LexicalPath.h * Forward slashes and multiple separators: C:/Windows///\\\notepad.exe Not supported: * Paths starting with two backslashes: \\?\C:\Windows, \\server\share * Unusual relative paths like C:, C:a\b, \, \a\b More on Windows path formats: https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats
This commit is contained in:
parent
9ebed7d8d5
commit
f026d495cd
Notes:
github-actions[bot]
2024-11-09 19:43:37 +00:00
Author: https://github.com/stasoid
Commit: f026d495cd
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1918
Reviewed-by: https://github.com/ADKaster ✅
4 changed files with 176 additions and 6 deletions
|
@ -58,6 +58,11 @@ LexicalPath::LexicalPath(ByteString path)
|
|||
}
|
||||
}
|
||||
|
||||
bool LexicalPath::is_absolute() const
|
||||
{
|
||||
return m_string.starts_with('/');
|
||||
}
|
||||
|
||||
Vector<ByteString> LexicalPath::parts() const
|
||||
{
|
||||
Vector<ByteString> vector;
|
||||
|
@ -163,7 +168,7 @@ ByteString LexicalPath::relative_path(StringView a_path, StringView a_prefix)
|
|||
if (prefix == "/"sv)
|
||||
return path.substring_view(1);
|
||||
|
||||
// NOTE: This means the prefix is a direct child of the path.
|
||||
// NOTE: This means the path is a direct child of the prefix.
|
||||
if (path.starts_with(prefix) && path[prefix.length()] == '/') {
|
||||
return path.substring_view(prefix.length() + 1);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue