( pathname: string, params: URLSearchParams | string, )
| 143 | }; |
| 144 | |
| 145 | export const getPathnameWithQuery = ( |
| 146 | pathname: string, |
| 147 | params: URLSearchParams | string, |
| 148 | ): string => { |
| 149 | const [basePath, existingQuery] = pathname.split('?'); |
| 150 | const merged = new URLSearchParams(existingQuery?.trim()); |
| 151 | const overrides = new URLSearchParams(params); |
| 152 | overrides.forEach((value, key) => { |
| 153 | merged.set(key, value); |
| 154 | }); |
| 155 | const queryString = merged.toString(); |
| 156 | |
| 157 | return `${basePath}${queryString ? `?${queryString}` : ''}`; |
| 158 | }; |
| 159 | |
| 160 | // For hrefs that must reach the webapp whoever renders them: on the extension |
| 161 | // a root-relative path resolves against `chrome-extension://<id>` and 404s. |
no outgoing calls
no test coverage detected