AK: Add URL::to_string_encoded()

The result of to_string() passed to urlencode(), with some characters
excluded - basically like JavaScript's encodeURI().
This commit is contained in:
Linus Groh 2021-01-31 18:37:12 +01:00 committed by Andreas Kling
parent 50e3b122c7
commit e0066ff2d7

View file

@ -28,6 +28,7 @@
#include <AK/String.h>
#include <AK/StringView.h>
#include <AK/URLParser.h>
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;