summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AK/URL.cpp10
-rw-r--r--AK/URL.h1
2 files changed, 11 insertions, 0 deletions
diff --git a/AK/URL.cpp b/AK/URL.cpp
index d029282b95..8c77031b88 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 4f827cbd03..be8bc05c93 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: