Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed URIResource.resolveSibling #3354

Merged
merged 2 commits into from Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -25,7 +25,7 @@ public Resource resolve(String other) {

@Override
public Resource resolveSibling(String other) {
return new URIResource(resolveSiblingPath(other), URI.create(getUri().toString().replaceFirst("/.*?$", "") + "/" + other));
return new URIResource(resolveSiblingPath(other), URI.create(getUri().toString().replaceFirst("/[^/]*$", "") + "/" + other));
}

@Override
Expand Down
@@ -1,10 +1,23 @@
package liquibase.resource

import spock.lang.Specification
import spock.lang.Unroll

class URIResourceAccessorTest extends Specification {

// "file:/c:/" | "file:/c:/"
// "http://example.local/nowhere.txt" | "http://example.local/nowhere.txt"
@Unroll
def resolveSibling() {
when:
def newResource = new URIResource(path, URI.create(uri)).resolveSibling(input)

then:
newResource.uri.toString() == expectedUri
newResource.path == expectedPath

where:
path | uri | input | expectedUri | expectedPath
"my/file.xml" | "file:/local/my/file.xml" | "other.csv" | "file:/local/my/other.csv" | "my/other.csv"
"liquibase/harness/data/changelogs/loadData.xml" | "jar:file:/C:/Users/example/liquibase-test-harness-1.0.6.jar!/liquibase/harness/data/changelogs/loadData.xml" | "load.csv" | "jar:file:/C:/Users/example/liquibase-test-harness-1.0.6.jar!/liquibase/harness/data/changelogs/load.csv" | "liquibase/harness/data/changelogs/load.csv"
"my/file.xml" | "http:/local/my/file.xml" | "other.csv" | "http:/local/my/other.csv" | "my/other.csv"
}
}