From e0066ff2d75089fb6ac31d90e69e844529f5f97f Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sun, 31 Jan 2021 18:37:12 +0100 Subject: [PATCH] AK: Add URL::to_string_encoded() The result of to_string() passed to urlencode(), with some characters excluded - basically like JavaScript's encodeURI(). --- AK/URL.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/AK/URL.h b/AK/URL.h index 96f96eb51b..3f6b965415 100644 --- a/AK/URL.h +++ b/AK/URL.h @@ -28,6 +28,7 @@ #include #include +#include namespace AK { @@ -63,6 +64,11 @@ public: String basename() const; String to_string() const; + String to_string_encoded() const + { + // Exclusion character set is the same JS's encodeURI() uses + return urlencode(to_string(), "#$&+,/:;=?@"); + } URL complete_url(const String&) const;