mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:44:58 +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:
parent
83d2c3f2f5
commit
4d81d868c7
2 changed files with 14 additions and 1 deletions
|
@ -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 {};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue