mirror of
https://github.com/openharmony/third_party_rust_rust-url.git
synced 2026-07-01 21:04:00 -04:00
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:
+1
-1
@@ -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 '/'.
|
||||
//
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user