mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 01:29:17 +00:00
AK: Make LexicalPath::relative_path() fallible
This commit is contained in:
parent
f026d495cd
commit
31bf40b659
Notes:
github-actions[bot]
2024-11-09 19:43:30 +00:00
Author: https://github.com/stasoid
Commit: 31bf40b659
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1918
Reviewed-by: https://github.com/ADKaster ✅
8 changed files with 12 additions and 14 deletions
|
@ -147,12 +147,10 @@ ByteString LexicalPath::absolute_path(ByteString dir_path, ByteString target)
|
|||
return LexicalPath::canonicalized_path(join(dir_path, target).string());
|
||||
}
|
||||
|
||||
ByteString LexicalPath::relative_path(StringView a_path, StringView a_prefix)
|
||||
Optional<ByteString> LexicalPath::relative_path(StringView a_path, StringView a_prefix)
|
||||
{
|
||||
if (!a_path.starts_with('/') || !a_prefix.starts_with('/')) {
|
||||
// FIXME: This should probably VERIFY or return an Optional<ByteString>.
|
||||
return ""sv;
|
||||
}
|
||||
if (!a_path.starts_with('/') || !a_prefix.starts_with('/'))
|
||||
return {};
|
||||
|
||||
if (a_path == a_prefix)
|
||||
return ".";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue