Fix Bug 14402: Main resource of http://www.apple.com/safari/ is called "www.apple...
authoraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Jun 2007 03:18:32 +0000 (03:18 +0000)
committeraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Jun 2007 03:18:32 +0000 (03:18 +0000)
The solution was to make KURL::lastPathComponent ignore trailing
slashes, which is what -[NSURL lastPathComponent] does, too.

Reviewed by Oliver.

* platform/KURL.cpp:
(WebCore::KURL::lastPathComponent):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@23779 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/KURL.cpp

index 491890802cc74d486bdd73dbad10609facc166d1..fd0ea441316f7b25a771d9f404f7637ede011aeb 100644 (file)
@@ -1,3 +1,16 @@
+2007-06-25  Adam Roben  <aroben@apple.com>
+
+        Fix Bug 14402: Main resource of http://www.apple.com/safari/ is called "www.apple.com" instead of "safari"
+        http://bugs.webkit.org/show_bug.cgi?id=14402
+
+        The solution was to make KURL::lastPathComponent ignore trailing
+        slashes, which is what -[NSURL lastPathComponent] does, too.
+
+        Reviewed by Oliver.
+
+        * platform/KURL.cpp:
+        (WebCore::KURL::lastPathComponent):
+
 2007-06-25  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Adam Roben.
index dd00f9667b84e9b8d53d40b24af0aa1ac2e0fd07..d8b27431fb8c9ed3d1045d6e31e2ddf17351481d 100644 (file)
@@ -490,8 +490,16 @@ DeprecatedString KURL::lastPathComponent() const
     if (!hasPath())
         return DeprecatedString();
 
-    int start = urlString.findRev('/', pathEndPos);    
-    return urlString.mid(start + 1, pathEndPos - start - 1);
+    int end = pathEndPos - 1;
+    if (urlString[end] == '/')
+        --end;
+
+    int start = urlString.findRev('/', end);
+    if (start < portEndPos)
+        return DeprecatedString();
+    ++start;
+
+    return urlString.mid(start, end - start + 1);
 }
 
 DeprecatedString KURL::protocol() const