| 102 | } |
| 103 | |
| 104 | function stripEmbeddedCredentials(url: string): string { |
| 105 | const authorityMarker = '//'; |
| 106 | const authorityMarkerIndex = url.indexOf(authorityMarker); |
| 107 | if (authorityMarkerIndex === -1) return url; |
| 108 | |
| 109 | const authorityStart = authorityMarkerIndex + authorityMarker.length; |
| 110 | const pathStart = url.indexOf('/', authorityStart); |
| 111 | const authorityEnd = pathStart === -1 ? url.length : pathStart; |
| 112 | const atIndex = url.lastIndexOf('@', authorityEnd - 1); |
| 113 | if (atIndex < authorityStart) return url; |
| 114 | |
| 115 | return `${url.slice(0, authorityStart)}${url.slice(atIndex + 1)}`; |
| 116 | } |
| 117 | |
| 118 | function coordinatesFromHostAndPath( |
| 119 | host: string, |