@@ -21,7 +21,6 @@ package cadence
2121import (
2222 "errors"
2323 "fmt"
24- "path/filepath"
2524 "strings"
2625
2726 "github.com/onflow/flow-cli/internal/util"
@@ -197,8 +196,8 @@ func (l *linter) handleImport(
197196 }, nil
198197 default :
199198 // Normalize relative path imports to absolute paths
200- if l . isPathLocation (importedLocation ) {
201- importedLocation = l . normalizePathLocation (checker .Location , importedLocation )
199+ if util . IsPathLocation (importedLocation ) {
200+ importedLocation = util . NormalizePathLocation (checker .Location , importedLocation )
202201 }
203202
204203 filepath , err := l .resolveImportFilepath (importedLocation , checker .Location )
@@ -244,37 +243,6 @@ func (l *linter) handleImport(
244243 }
245244}
246245
247- // isPathLocation returns true if the location is a file path (contains .cdc)
248- func (l * linter ) isPathLocation (location common.Location ) bool {
249- stringLocation , ok := location .(common.StringLocation )
250- if ! ok {
251- return false
252- }
253- return strings .Contains (stringLocation .String (), ".cdc" )
254- }
255-
256- // normalizePathLocation normalizes a relative path import against a base location
257- func (l * linter ) normalizePathLocation (base , relative common.Location ) common.Location {
258- baseString , baseOk := base .(common.StringLocation )
259- relativeString , relativeOk := relative .(common.StringLocation )
260-
261- if ! baseOk || ! relativeOk {
262- return relative
263- }
264-
265- basePath := baseString .String ()
266- relativePath := relativeString .String ()
267-
268- // If the relative path is absolute, return it as-is
269- if filepath .IsAbs (relativePath ) {
270- return relative
271- }
272-
273- // Join relative to the parent directory of the base
274- normalizedPath := filepath .Join (filepath .Dir (basePath ), relativePath )
275- return common .StringLocation (normalizedPath )
276- }
277-
278246func (l * linter ) resolveImportFilepath (
279247 location common.Location ,
280248 parentLocation common.Location ,
0 commit comments