diff --git a/AK/URL.cpp b/AK/URL.cpp index d029282b959..8c77031b881 100644 --- a/AK/URL.cpp +++ b/AK/URL.cpp @@ -297,4 +297,14 @@ URL URL::create_with_file_protocol(const String& path) return url; } +URL URL::create_with_url_or_path(const String& url_or_path) +{ + URL url = url_or_path; + if (url.is_valid()) + return url; + + String path = canonicalized_path(url_or_path); + return URL::create_with_file_protocol(path); +} + } diff --git a/AK/URL.h b/AK/URL.h index 4f827cbd033..be8bc05c939 100644 --- a/AK/URL.h +++ b/AK/URL.h @@ -65,6 +65,7 @@ public: URL complete_url(const String&) const; + static URL create_with_url_or_path(const String& url_or_path); static URL create_with_file_protocol(const String& path); private: