Merge pull request #754 from dsherret/make_relative_include_filename_other_directory

fix: make_relative missing filename when filenames equal in both urls
This commit is contained in:
Valentin Gosu
2022-06-10 22:18:25 +02:00
committed by GitHub
2 changed files with 11 additions and 1 deletions
+1 -1
View File
@@ -468,7 +468,7 @@ impl Url {
}
// Add the filename if they are not the same
if base_filename != url_filename {
if !relative.is_empty() || base_filename != url_filename {
// If the URIs filename is empty this means that it was a directory
// so we'll have to append a '/'.
//
+10
View File
@@ -1084,6 +1084,16 @@ fn test_make_relative() {
"http://127.0.0.1:8080/test/video?baz=meh#456",
"video?baz=meh#456",
),
(
"http://127.0.0.1:8080/file.txt",
"http://127.0.0.1:8080/test/file.txt",
"test/file.txt",
),
(
"http://127.0.0.1:8080/not_equal.txt",
"http://127.0.0.1:8080/test/file.txt",
"test/file.txt",
),
];
for (base, uri, relative) in &tests {