add URI.FindIn(SearchPath) to resolve relative paths
This commit is contained in:
parent
35899c86a5
commit
1b0cd57284
@ -57,6 +57,13 @@ func (u URI) Parse() data.URIParser {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *URI) FindIn(s *SearchPath) {
|
||||||
|
if s == nil {
|
||||||
|
s = NewSearchPath(ConfigKey("system.importpath").GetStringSlice())
|
||||||
|
}
|
||||||
|
*u = s.FindURI(*u)
|
||||||
|
}
|
||||||
|
|
||||||
func (u URI) Exists() bool {
|
func (u URI) Exists() bool {
|
||||||
return transport.ExistsURI(string(u))
|
return transport.ExistsURI(string(u))
|
||||||
}
|
}
|
||||||
|
@ -37,3 +37,13 @@ func TestURINewResource(t *testing.T) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestURIFindIn(t *testing.T) {
|
||||||
|
searchPath := NewSearchPath(ConfigKey("system.importpath").GetStringSlice())
|
||||||
|
assert.Nil(t, searchPath.AddPath(string(TempDir)))
|
||||||
|
assert.Nil(t, TempDir.CreateFile("bar", "testdata"))
|
||||||
|
|
||||||
|
var file URI = "file://bar"
|
||||||
|
file.FindIn(searchPath)
|
||||||
|
assert.True(t, file.Exists())
|
||||||
|
assert.Equal(t, string(file), fmt.Sprintf("file://%s/bar", TempDir))
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user