MCPcopy Index your code
hub / github.com/microsoft/typescript-go / GetRelativePathToDirectoryOrUrl

Function GetRelativePathToDirectoryOrUrl

internal/tspath/path.go:793–812  ·  view source on GitHub ↗
(directoryPathOrUrl string, relativeOrAbsolutePath string, isAbsolutePathAnUrl bool, options ComparePathsOptions)

Source from the content-addressed store, hash-verified

791}
792
793func GetRelativePathToDirectoryOrUrl(directoryPathOrUrl string, relativeOrAbsolutePath string, isAbsolutePathAnUrl bool, options ComparePathsOptions) string {
794 pathComponents := GetPathComponentsRelativeTo(
795 directoryPathOrUrl,
796 relativeOrAbsolutePath,
797 options,
798 )
799
800 firstComponent := pathComponents[0]
801 if isAbsolutePathAnUrl && IsRootedDiskPath(firstComponent) {
802 var prefix string
803 if firstComponent[0] == DirectorySeparator {
804 prefix = "file://"
805 } else {
806 prefix = "file:///"
807 }
808 pathComponents[0] = prefix + firstComponent
809 }
810
811 return GetPathFromPathComponents(pathComponents)
812}
813
814// Gets the portion of a path following the last (non-terminal) separator (`/`).
815// Semantics align with NodeJS's `path.basename` except that we support URL's as well.

Callers 6

getSourceMappingURLMethod · 0.92
getReferencedFilesMethod · 0.92
AddSourceMethod · 0.92
ConvertToRelativePathFunction · 0.85

Calls 3

IsRootedDiskPathFunction · 0.85

Tested by 1