(params: URLSearchParams)
| 196 | }; |
| 197 | |
| 198 | export const getRedirectNextPath = (params: URLSearchParams): string => { |
| 199 | const next = params.get('next'); |
| 200 | |
| 201 | let nextPath = '/'; |
| 202 | |
| 203 | if (next) { |
| 204 | try { |
| 205 | const nextUrl = new URL(next, 'http://localhost'); |
| 206 | // infinite redirect loop prevention |
| 207 | nextUrl.searchParams.delete('next'); |
| 208 | |
| 209 | // we ignore url origin since we don't allow cross-origin redirects |
| 210 | nextPath = getPathnameWithQuery(nextUrl.pathname, nextUrl.searchParams); |
| 211 | } catch (error) { |
| 212 | // eslint-disable-next-line no-console |
| 213 | console.error(error); |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | return checkIsExtension() ? `${webappUrl}${nextPath}` : nextPath; |
| 218 | }; |
| 219 | |
| 220 | // Extension routes don't exist on the webapp, so `next` is dropped there. |
| 221 | export const getBuyCoresUrl = ({ |
no test coverage detected