|
1 |
| -/* |
2 |
| -Copyright (c) 2024-2024 VMware, Inc. All Rights Reserved. |
3 |
| -
|
4 |
| -Licensed under the Apache License, Version 2.0 (the "License"); |
5 |
| -you may not use this file except in compliance with the License. |
6 |
| -You may obtain a copy of the License at |
7 |
| -
|
8 |
| -http://www.apache.org/licenses/LICENSE-2.0 |
9 |
| -
|
10 |
| -Unless required by applicable law or agreed to in writing, software |
11 |
| -distributed under the License is distributed on an "AS IS" BASIS, |
12 |
| -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 |
| -See the License for the specific language governing permissions and |
14 |
| -limitations under the License. |
15 |
| -*/ |
| 1 | +// © Broadcom. All Rights Reserved. |
| 2 | +// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. |
| 3 | +// SPDX-License-Identifier: Apache-2.0 |
16 | 4 |
|
17 | 5 | package importer
|
18 | 6 |
|
@@ -112,8 +100,15 @@ type FileArchive struct {
|
112 | 100 |
|
113 | 101 | func (t *FileArchive) Open(name string) (io.ReadCloser, int64, error) {
|
114 | 102 | fpath := name
|
115 |
| - if name != t.Path && !filepath.IsAbs(name) { |
116 |
| - fpath = filepath.Join(filepath.Dir(t.Path), name) |
| 103 | + if name != t.Path { |
| 104 | + if IsRemotePath(t.Path) { |
| 105 | + index := strings.LastIndex(t.Path, "/") |
| 106 | + if index != -1 { |
| 107 | + fpath = t.Path[:index] + "/" + name |
| 108 | + } |
| 109 | + } else if !filepath.IsAbs(name) { |
| 110 | + fpath = filepath.Join(filepath.Dir(t.Path), name) |
| 111 | + } |
117 | 112 | }
|
118 | 113 |
|
119 | 114 | return t.OpenFile(fpath)
|
|
0 commit comments