mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-28 21:54:40 +03:00
AK: Make LexicalPath take String instead of StringView
This commit is contained in:
parent
e873d27ab1
commit
f7139d9422
Notes:
sideshowbarker
2024-07-18 19:32:47 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/f7139d9422f
@ -31,8 +31,8 @@
|
||||
|
||||
namespace AK {
|
||||
|
||||
LexicalPath::LexicalPath(const StringView& s)
|
||||
: m_string(s)
|
||||
LexicalPath::LexicalPath(String s)
|
||||
: m_string(move(s))
|
||||
{
|
||||
canonicalize();
|
||||
m_is_valid = true;
|
||||
@ -114,12 +114,12 @@ bool LexicalPath::has_extension(const StringView& extension) const
|
||||
return m_string.ends_with(extension, CaseSensitivity::CaseInsensitive);
|
||||
}
|
||||
|
||||
String LexicalPath::canonicalized_path(const StringView& path)
|
||||
String LexicalPath::canonicalized_path(String path)
|
||||
{
|
||||
return LexicalPath(path).string();
|
||||
return LexicalPath(move(path)).string();
|
||||
}
|
||||
|
||||
String LexicalPath::relative_path(const String absolute_path, const String& prefix)
|
||||
String LexicalPath::relative_path(String absolute_path, const String& prefix)
|
||||
{
|
||||
if (!LexicalPath { absolute_path }.is_absolute() || !LexicalPath { prefix }.is_absolute())
|
||||
return {};
|
||||
|
@ -34,7 +34,7 @@ namespace AK {
|
||||
class LexicalPath {
|
||||
public:
|
||||
LexicalPath() = default;
|
||||
explicit LexicalPath(const StringView&);
|
||||
explicit LexicalPath(String);
|
||||
|
||||
bool is_valid() const { return m_is_valid; }
|
||||
bool is_absolute() const { return m_is_absolute; }
|
||||
@ -49,8 +49,8 @@ public:
|
||||
|
||||
bool has_extension(const StringView&) const;
|
||||
|
||||
static String canonicalized_path(const StringView&);
|
||||
static String relative_path(const String absolute_path, const String& prefix);
|
||||
static String canonicalized_path(String);
|
||||
static String relative_path(String absolute_path, String const& prefix);
|
||||
|
||||
private:
|
||||
void canonicalize();
|
||||
|
Loading…
Reference in New Issue
Block a user