MCPcopy Create free account
hub / github.com/microsoft/typescript-go / ResolvePath

Function ResolvePath

internal/tspath/path.go:322–330  ·  view source on GitHub ↗

Combines and resolves paths. If a path is absolute, it replaces any previous path. Any `.` and `..` path components are resolved. Trailing directory separators are preserved. ```go resolvePath("/path", "to", "file.ext") == "path/to/file.ext" resolvePath("/path", "to", "file.ext/") == "path/to/file.

(path string, paths ...string)

Source from the content-addressed store, hash-verified

320// resolvePath("/path", "dir", "..", "to", "file.ext") == "path/to/file.ext"
321// ```
322func ResolvePath(path string, paths ...string) string {
323 var combinedPath string
324 if len(paths) > 0 {
325 combinedPath = CombinePaths(path, paths...)
326 } else {
327 combinedPath = NormalizeSlashes(path)
328 }
329 return NormalizePath(combinedPath)
330}
331
332func ResolveTripleslashReference(moduleName string, containingFile string) string {
333 basePath := GetDirectoryPath(containingFile)

Calls 4

lenFunction · 0.85
CombinePathsFunction · 0.85
NormalizeSlashesFunction · 0.85
NormalizePathFunction · 0.85

Tested by 1

TestResolvePathFunction · 0.68