diff options
author | MacDue <macdue@dueutil.tech> | 2023-04-13 23:29:51 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-04-15 06:37:04 +0200 |
commit | 5db1eb996173b34960f48c7ea8ce4fd33acde157 (patch) | |
tree | 3821497e14788bebd9a675ca44d73d574cb3f420 /Tests | |
parent | 35612c6a7f7602ff46d56bbbbc8b33b28b411409 (diff) | |
download | serenity-5db1eb996173b34960f48c7ea8ce4fd33acde157.zip |
AK+Everywhere: Replace URL::paths() with path_segment_at_index()
This allows accessing and looping over the path segments in a URL
without necessarily allocating a new vector if you want them percent
decoded too (which path_segment_at_index() has an option for).
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/AK/TestURL.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/Tests/AK/TestURL.cpp b/Tests/AK/TestURL.cpp index c886b313f1..52024c64a0 100644 --- a/Tests/AK/TestURL.cpp +++ b/Tests/AK/TestURL.cpp @@ -203,8 +203,8 @@ TEST_CASE(mailto_url) EXPECT_EQ(url.scheme(), "mailto"); EXPECT(url.host().is_null()); EXPECT_EQ(url.port_or_default(), 0); - EXPECT_EQ(url.paths().size(), 1u); - EXPECT_EQ(url.paths()[0], "mail@example.com"); + EXPECT_EQ(url.path_segment_count(), 1u); + EXPECT_EQ(url.path_segment_at_index(0), "mail@example.com"); EXPECT(url.query().is_null()); EXPECT(url.fragment().is_null()); EXPECT_EQ(url.serialize(), "mailto:mail@example.com"); @@ -329,20 +329,20 @@ TEST_CASE(create_with_file_scheme) EXPECT(url.is_valid()); EXPECT_EQ(url.scheme(), "file"); EXPECT_EQ(url.port_or_default(), 0); - EXPECT_EQ(url.paths().size(), 3u); - EXPECT_EQ(url.paths()[0], "home"); - EXPECT_EQ(url.paths()[1], "anon"); - EXPECT_EQ(url.paths()[2], "README.md"); + EXPECT_EQ(url.path_segment_count(), 3u); + EXPECT_EQ(url.path_segment_at_index(0), "home"); + EXPECT_EQ(url.path_segment_at_index(1), "anon"); + EXPECT_EQ(url.path_segment_at_index(2), "README.md"); EXPECT_EQ(url.serialize_path(), "/home/anon/README.md"); EXPECT(url.query().is_null()); EXPECT(url.fragment().is_null()); url = URL::create_with_file_scheme("/home/anon/"); EXPECT(url.is_valid()); - EXPECT_EQ(url.paths().size(), 3u); - EXPECT_EQ(url.paths()[0], "home"); - EXPECT_EQ(url.paths()[1], "anon"); - EXPECT_EQ(url.paths()[2], ""); + EXPECT_EQ(url.path_segment_count(), 3u); + EXPECT_EQ(url.path_segment_at_index(0), "home"); + EXPECT_EQ(url.path_segment_at_index(1), "anon"); + EXPECT_EQ(url.path_segment_at_index(2), ""); EXPECT_EQ(url.serialize_path(), "/home/anon/"); url = URL("file:///home/anon/"sv); @@ -399,9 +399,9 @@ TEST_CASE(complete_file_url_with_base) URL url { "file:///home/index.html" }; EXPECT(url.is_valid()); EXPECT_EQ(url.serialize_path(), "/home/index.html"); - EXPECT_EQ(url.paths().size(), 2u); - EXPECT_EQ(url.paths()[0], "home"); - EXPECT_EQ(url.paths()[1], "index.html"); + EXPECT_EQ(url.path_segment_count(), 2u); + EXPECT_EQ(url.path_segment_at_index(0), "home"); + EXPECT_EQ(url.path_segment_at_index(1), "index.html"); auto sub_url = url.complete_url("js/app.js"sv); EXPECT(sub_url.is_valid()); |