( url: string, params: UrlParams.UrlParams, hash: string | undefined )
| 36 | * @since 4.0.0 |
| 37 | */ |
| 38 | export const make = ( |
| 39 | url: string, |
| 40 | params: UrlParams.UrlParams, |
| 41 | hash: string | undefined |
| 42 | ): Result.Result<URL, UrlError> => |
| 43 | Result.try({ |
| 44 | try: () => { |
| 45 | const urlInstance = new URL(url, baseUrl()) |
| 46 | for (let i = 0; i < params.params.length; i++) { |
| 47 | const [key, value] = params.params[i] |
| 48 | if (value !== undefined) { |
| 49 | urlInstance.searchParams.append(key, value) |
| 50 | } |
| 51 | } |
| 52 | if (hash !== undefined) { |
| 53 | urlInstance.hash = hash |
| 54 | } |
| 55 | return urlInstance |
| 56 | }, |
| 57 | catch: (cause) => new UrlError({ cause }) |
| 58 | }) |
| 59 | |
| 60 | const baseUrl = (): string | undefined => { |
| 61 | if ( |
no test coverage detected