( rewrite: LocationRewrite | undefined, url: URL, )
| 61 | /** Execute a location input rewrite if provided. */ |
| 62 | /** Execute a location input rewrite if provided. */ |
| 63 | export function executeRewriteInput( |
| 64 | rewrite: LocationRewrite | undefined, |
| 65 | url: URL, |
| 66 | ): URL { |
| 67 | const res = rewrite?.input?.({ url }) |
| 68 | if (res) { |
| 69 | if (typeof res === 'string') { |
| 70 | return new URL(res) |
| 71 | } else if (res instanceof URL) { |
| 72 | return res |
| 73 | } |
| 74 | } |
| 75 | return url |
| 76 | } |
| 77 | |
| 78 | /** Execute a location output rewrite if provided. */ |
| 79 | /** Execute a location output rewrite if provided. */ |
no test coverage detected