mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 10:08:10 +00:00
AK: Implement a way to resolve relative paths lexically
This commit is contained in:
parent
24e7196158
commit
50ad294527
3 changed files with 22 additions and 0 deletions
|
@ -121,6 +121,14 @@ String LexicalPath::canonicalized_path(String path)
|
|||
return builder.to_string();
|
||||
}
|
||||
|
||||
String LexicalPath::absolute_path(String dir_path, String target)
|
||||
{
|
||||
if (LexicalPath(target).is_absolute()) {
|
||||
return LexicalPath::canonicalized_path(target);
|
||||
}
|
||||
return LexicalPath::canonicalized_path(join(dir_path, target).string());
|
||||
}
|
||||
|
||||
String LexicalPath::relative_path(StringView const& a_path, StringView const& a_prefix)
|
||||
{
|
||||
if (!a_path.starts_with('/') || !a_prefix.starts_with('/')) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue