(value: string)
| 30 | .trim(); |
| 31 | |
| 32 | export const normalizeUrl = (value: string) => { |
| 33 | try { |
| 34 | const url = new URL(value.trim()); |
| 35 | |
| 36 | if (url.protocol !== 'http:' && url.protocol !== 'https:') { |
| 37 | return ''; |
| 38 | } |
| 39 | |
| 40 | url.hash = ''; |
| 41 | return url.toString().replace(/\/$/, ''); |
| 42 | } catch { |
| 43 | return ''; |
| 44 | } |
| 45 | }; |
| 46 | |
| 47 | export const isSupportedUrl = (value: string) => normalizeUrl(value) !== ''; |
| 48 |
no outgoing calls
no test coverage detected