mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
AK: Update LexicalPath::relative_path to work for '/' prefix
If the prefix path is just a slash the LexicalPath was removing too many characters. Now only remove an extra character if the prefix is not just the root path.
This commit is contained in:
committed by
Andreas Kling
parent
83d2c3f2f5
commit
4d81d868c7
@@ -127,7 +127,9 @@ String LexicalPath::relative_path(const String absolute_path, const String& pref
|
||||
if (!absolute_path.starts_with(prefix))
|
||||
return absolute_path;
|
||||
|
||||
size_t prefix_length = LexicalPath { prefix }.string().length() + 1;
|
||||
size_t prefix_length = LexicalPath { prefix }.string().length();
|
||||
if (prefix != "/")
|
||||
prefix_length++;
|
||||
if (prefix_length >= absolute_path.length())
|
||||
return {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user