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