diff options
author | Andreas Kling <kling@serenityos.org> | 2021-06-01 13:11:14 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-01 13:22:04 +0200 |
commit | c0d1a7588153d35f06a9ff5d009261099e6fc647 (patch) | |
tree | 6f0d66864be83f860bd9d3b8a6ea5277f2b5a839 /Tests | |
parent | 468bb546775dcbc14e4a83ad76b63ad432a9f2ad (diff) | |
download | serenity-c0d1a7588153d35f06a9ff5d009261099e6fc647.zip |
AK: Strip leading/trailing C0-control-or-space in URLs correctly
We have to stop scanning once we hit a non-strippable character.
Add some tests to cover this.
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/AK/TestURL.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Tests/AK/TestURL.cpp b/Tests/AK/TestURL.cpp index 3fd1413f1d..9fff681525 100644 --- a/Tests/AK/TestURL.cpp +++ b/Tests/AK/TestURL.cpp @@ -307,3 +307,24 @@ TEST_CASE(complete_url) EXPECT(base_url.complete_url("../index.html#fragment").equals(base_url)); } + +TEST_CASE(leading_whitespace) +{ + URL url { " https://foo.com/" }; + EXPECT(url.is_valid()); + EXPECT_EQ(url.to_string(), "https://foo.com/"); +} + +TEST_CASE(trailing_whitespace) +{ + URL url { "https://foo.com/ " }; + EXPECT(url.is_valid()); + EXPECT_EQ(url.to_string(), "https://foo.com/"); +} + +TEST_CASE(leading_and_trailing_whitespace) +{ + URL url { " https://foo.com/ " }; + EXPECT(url.is_valid()); + EXPECT_EQ(url.to_string(), "https://foo.com/"); +} |