| 791 | } |
| 792 | |
| 793 | func 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. |