aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugofs
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2024-02-24 11:51:16 +0100
committerBjørn Erik Pedersen <[email protected]>2024-02-24 16:41:18 +0100
commit189b72331e02a17e25f5102af02486d25e27e826 (patch)
tree5b9b0c74c19acaa91214756df47472cc18cea76f /hugofs
parentb2b7bfdd3abfd389d20e59b256104dd06bbcd951 (diff)
downloadhugo-189b72331e02a17e25f5102af02486d25e27e826.tar.gz
hugo-189b72331e02a17e25f5102af02486d25e27e826.zip
tocss: Fix the import resolving from absolute to relative assets paths
Fixes #12137
Diffstat (limited to 'hugofs')
-rw-r--r--hugofs/rootmapping_fs.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/hugofs/rootmapping_fs.go b/hugofs/rootmapping_fs.go
index ce4243fbb..9a89914be 100644
--- a/hugofs/rootmapping_fs.go
+++ b/hugofs/rootmapping_fs.go
@@ -338,12 +338,17 @@ func (c ComponentPath) ComponentPathJoined() string {
type ReverseLookupProvder interface {
ReverseLookup(filename string, checkExists bool) ([]ComponentPath, error)
+ ReverseLookupComponent(component, filename string, checkExists bool) ([]ComponentPath, error)
}
// func (fs *RootMappingFs) ReverseStat(filename string) ([]FileMetaInfo, error)
-func (fs *RootMappingFs) ReverseLookup(in string, checkExists bool) ([]ComponentPath, error) {
- in = fs.cleanName(in)
- key := filepathSeparator + in
+func (fs *RootMappingFs) ReverseLookup(filename string, checkExists bool) ([]ComponentPath, error) {
+ return fs.ReverseLookupComponent("", filename, checkExists)
+}
+
+func (fs *RootMappingFs) ReverseLookupComponent(component, filename string, checkExists bool) ([]ComponentPath, error) {
+ filename = fs.cleanName(filename)
+ key := filepathSeparator + filename
s, roots := fs.getRootsReverse(key)
@@ -357,6 +362,9 @@ func (fs *RootMappingFs) ReverseLookup(in string, checkExists bool) ([]Component
dir, name := filepath.Split(base)
for _, first := range roots {
+ if component != "" && first.FromBase != component {
+ continue
+ }
if first.Meta.Rename != nil {
name = first.Meta.Rename(name, true)
}