(url: string | undefined)
| 1 | const hideKeyFromUrl = (url: string | undefined) => { |
| 2 | if (!url) return url; |
| 3 | |
| 4 | const regex = /^(https?:\/\/)(.*)$/; |
| 5 | const match = url.match(regex); |
| 6 | |
| 7 | if (match) { |
| 8 | const protocol = match[1]; |
| 9 | let restOfUrl = match[2]; |
| 10 | |
| 11 | // eslint-disable-next-line no-useless-escape |
| 12 | restOfUrl = restOfUrl.replace(/\/[^\/]*$/, ''); |
| 13 | return protocol + restOfUrl; |
| 14 | } |
| 15 | |
| 16 | return url?.substring(0, url.lastIndexOf('/')); |
| 17 | }; |
| 18 | |
| 19 | export default hideKeyFromUrl; |
no outgoing calls
no test coverage detected