Jelajahi Sumber

fix: relative URI needs to support "./" prefixes

Sam Jaffe 2 minggu lalu
induk
melakukan
13651debf0
1 mengubah file dengan 7 tambahan dan 2 penghapusan
  1. 7 2
      include/jvalidate/uri.h

+ 7 - 2
include/jvalidate/uri.h

@@ -83,8 +83,13 @@ public:
    * to replace everything after the hostname with the contents of relative.
    */
   URI operator/(URI const & relative) const {
-    std::string div = uri_.ends_with("/") || relative.uri_.starts_with("/") ? "" : "/";
-    return URI(uri_ + div + relative.uri_);
+    if (relative.uri_.starts_with("/")) {
+      return URI(uri_ + relative.uri_);
+    }
+    if (relative.uri_.starts_with("./")) {
+      return URI(uri_ + relative.uri_.substr(1));
+    }
+    return URI(uri_ + "/" + relative.uri_);
   }
 
   /**