| 137 | } |
| 138 | |
| 139 | export class ExtUri implements IExtUri { |
| 140 | constructor(private _ignorePathCasing: (uri: URI) => boolean) {} |
| 141 | |
| 142 | compare(uri1: URI, uri2: URI, ignoreFragment: boolean = false): number { |
| 143 | if (uri1 === uri2) { |
| 144 | return 0; |
| 145 | } |
| 146 | return strCompare(this.getComparisonKey(uri1, ignoreFragment), this.getComparisonKey(uri2, ignoreFragment)); |
| 147 | } |
| 148 | |
| 149 | isEqual(uri1: URI | undefined, uri2: URI | undefined, ignoreFragment: boolean = false): boolean { |
| 150 | if (uri1 === uri2) { |
| 151 | return true; |
| 152 | } |
| 153 | if (!uri1 || !uri2) { |
| 154 | return false; |
| 155 | } |
| 156 | return this.getComparisonKey(uri1, ignoreFragment) === this.getComparisonKey(uri2, ignoreFragment); |
| 157 | } |
| 158 | |
| 159 | getComparisonKey(uri: URI, ignoreFragment: boolean = false): string { |
| 160 | return uri |
| 161 | .with({ |
| 162 | path: this._ignorePathCasing(uri) ? uri.path.toLowerCase() : undefined, |
| 163 | fragment: ignoreFragment ? undefined : undefined |
| 164 | }) |
| 165 | .toString(); |
| 166 | } |
| 167 | |
| 168 | ignorePathCasing(uri: URI): boolean { |
| 169 | return this._ignorePathCasing(uri); |
| 170 | } |
| 171 | |
| 172 | isEqualOrParent( |
| 173 | base: URI, |
| 174 | parentCandidate: URI, |
| 175 | ignoreFragment: boolean = false, |
| 176 | sep: '\\' | '/' = isWindows ? '\\' : '/' |
| 177 | ): boolean { |
| 178 | if (base.scheme === parentCandidate.scheme) { |
| 179 | if (base.scheme === Schemas.file) { |
| 180 | return ( |
| 181 | extpath.isEqualOrParent( |
| 182 | originalFSPath(base), |
| 183 | originalFSPath(parentCandidate), |
| 184 | this._ignorePathCasing(base), |
| 185 | sep |
| 186 | ) && |
| 187 | base.query === parentCandidate.query && |
| 188 | (ignoreFragment || base.fragment === parentCandidate.fragment) |
| 189 | ); |
| 190 | } |
| 191 | if (isEqualAuthority(base.authority, parentCandidate.authority)) { |
| 192 | return ( |
| 193 | extpath.isEqualOrParent(base.path, parentCandidate.path, this._ignorePathCasing(base), '/') && |
| 194 | base.query === parentCandidate.query && |
| 195 | (ignoreFragment || base.fragment === parentCandidate.fragment) |
| 196 | ); |
nothing calls this directly
no outgoing calls
no test coverage detected