Title: [210365] trunk
Revision
210365
Author
krol...@apple.com
Date
2017-01-05 11:18:03 -0800 (Thu, 05 Jan 2017)

Log Message

Add WebCore::URL::protocolHostAndPort
https://bugs.webkit.org/show_bug.cgi?id=166426

Reviewed by Alex Christensen.

Source/WebCore:

Added to support record/replay mechanism, which needs it in order to
implement fuzzy-matching of URLs that are similar to each other but
that nonetheless come from the same source/host.

Updated TestWebKitAPI/Tests/WebCore/URL.cpp.

* platform/URL.cpp:
(WebCore::URL::protocolHostAndPort):
* platform/URL.h:

Tools:

Add test for protocolHostAndPort.

* TestWebKitAPI/Tests/WebCore/URL.cpp:
(TestWebKitAPI::TEST_F):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (210364 => 210365)


--- trunk/Source/WebCore/ChangeLog	2017-01-05 19:10:23 UTC (rev 210364)
+++ trunk/Source/WebCore/ChangeLog	2017-01-05 19:18:03 UTC (rev 210365)
@@ -1,3 +1,20 @@
+2017-01-05  Keith Rollin  <krol...@apple.com>
+
+        Add WebCore::URL::protocolHostAndPort
+        https://bugs.webkit.org/show_bug.cgi?id=166426
+
+        Reviewed by Alex Christensen.
+
+        Added to support record/replay mechanism, which needs it in order to
+        implement fuzzy-matching of URLs that are similar to each other but
+        that nonetheless come from the same source/host.
+
+        Updated TestWebKitAPI/Tests/WebCore/URL.cpp.
+
+        * platform/URL.cpp:
+        (WebCore::URL::protocolHostAndPort):
+        * platform/URL.h:
+
 2017-01-05  Chris Dumez  <cdu...@apple.com>
 
         Form validation: Align email validation with the latest HTML specification

Modified: trunk/Source/WebCore/platform/URL.cpp (210364 => 210365)


--- trunk/Source/WebCore/platform/URL.cpp	2017-01-05 19:10:23 UTC (rev 210364)
+++ trunk/Source/WebCore/platform/URL.cpp	2017-01-05 19:18:03 UTC (rev 210365)
@@ -717,6 +717,18 @@
     return host();
 }
 
+String URL::protocolHostAndPort() const
+{
+    String result = m_string.substring(0, m_portEnd);
+
+    if (m_passwordEnd - m_userStart > 0) {
+        const int allowForTrailingAtSign = 1;
+        result.remove(m_userStart, m_passwordEnd - m_userStart + allowForTrailingAtSign);
+    }
+
+    return result;
+}
+
 String URL::user() const
 {
     return decodeURLEscapeSequences(m_string.substring(m_userStart, m_userEnd - m_userStart));

Modified: trunk/Source/WebCore/platform/URL.h (210364 => 210365)


--- trunk/Source/WebCore/platform/URL.h	2017-01-05 19:10:23 UTC (rev 210364)
+++ trunk/Source/WebCore/platform/URL.h	2017-01-05 19:18:03 UTC (rev 210365)
@@ -104,6 +104,7 @@
     WEBCORE_EXPORT String host() const;
     WEBCORE_EXPORT std::optional<uint16_t> port() const;
     WEBCORE_EXPORT String hostAndPort() const;
+    WEBCORE_EXPORT String protocolHostAndPort() const;
     WEBCORE_EXPORT String user() const;
     WEBCORE_EXPORT String pass() const;
     WEBCORE_EXPORT String path() const;

Modified: trunk/Tools/ChangeLog (210364 => 210365)


--- trunk/Tools/ChangeLog	2017-01-05 19:10:23 UTC (rev 210364)
+++ trunk/Tools/ChangeLog	2017-01-05 19:18:03 UTC (rev 210365)
@@ -1,3 +1,15 @@
+2017-01-05  Keith Rollin  <krol...@apple.com>
+
+        Add WebCore::URL::protocolHostAndPort
+        https://bugs.webkit.org/show_bug.cgi?id=166426
+
+        Reviewed by Alex Christensen.
+
+        Add test for protocolHostAndPort.
+
+        * TestWebKitAPI/Tests/WebCore/URL.cpp:
+        (TestWebKitAPI::TEST_F):
+
 2017-01-05  Per Arne Vollan  <pvol...@apple.com>
 
         [Win] Archive test result is failing.

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/URL.cpp (210364 => 210365)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/URL.cpp	2017-01-05 19:10:23 UTC (rev 210364)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/URL.cpp	2017-01-05 19:18:03 UTC (rev 210365)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "WTFStringUtilities.h"
 #include <WebCore/URL.h>
+#include <WebCore/URLParser.h>
 #include <wtf/MainThread.h>
 
 using namespace WebCore;
@@ -70,6 +71,53 @@
     EXPECT_EQ(String("fragment"), kurl.fragmentIdentifier());
 }
 
+TEST_F(URLTest, URLProtocolHostAndPort)
+{
+    auto createURL = [](const char* urlAsString) {
+        URLParser parser(urlAsString);
+        return parser.result();
+    };
+
+    auto url = ""
+    EXPECT_EQ(String("http://www.example.com:8080"), url.protocolHostAndPort());
+
+    url = ""
+    EXPECT_EQ(String("http://www.example.com:8080"), url.protocolHostAndPort());
+
+    url = ""
+    EXPECT_EQ(String("http://www.example.com:8080"), url.protocolHostAndPort());
+
+    url = ""
+    EXPECT_EQ(String("http://www.example.com:8080"), url.protocolHostAndPort());
+
+    url = ""
+    EXPECT_EQ(String("http://www.example.com:8080"), url.protocolHostAndPort());
+
+    url = ""
+    EXPECT_EQ(String("http://www.example.com"), url.protocolHostAndPort());
+
+    url = ""
+    EXPECT_EQ(String("http://www.example.com"), url.protocolHostAndPort());
+
+    url = ""
+    EXPECT_EQ(String("file://"), url.protocolHostAndPort());
+
+    url = ""
+    EXPECT_EQ(String("file://"), url.protocolHostAndPort());
+
+    url = ""
+    EXPECT_EQ(String("file://"), url.protocolHostAndPort());
+
+    url = ""
+    EXPECT_EQ(String("file://"), url.protocolHostAndPort());
+
+    url = ""
+    EXPECT_EQ(String("asdf://www.example.com:8080"), url.protocolHostAndPort());
+
+    url = ""
+    EXPECT_EQ(String("asdf://"), url.protocolHostAndPort());
+}
+
 TEST_F(URLTest, URLDataURIStringSharing)
 {
     URL baseURL(ParsedURLString, "http://www.webkit.org/");
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to