(params: URLSearchParams)
| 143 | }; |
| 144 | |
| 145 | export const getRedirectNextPath = (params: URLSearchParams): string => { |
| 146 | const next = params.get('next'); |
| 147 | |
| 148 | let nextPath = '/'; |
| 149 | |
| 150 | if (next) { |
| 151 | try { |
| 152 | const nextUrl = new URL(next, 'http://localhost'); |
| 153 | // infinite redirect loop prevention |
| 154 | nextUrl.searchParams.delete('next'); |
| 155 | |
| 156 | // we ignore url origin since we don't allow cross-origin redirects |
| 157 | nextPath = getPathnameWithQuery(nextUrl.pathname, nextUrl.searchParams); |
| 158 | } catch (error) { |
| 159 | // eslint-disable-next-line no-console |
| 160 | console.error(error); |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | return checkIsExtension() ? `${webappUrl}${nextPath}` : nextPath; |
| 165 | }; |
no test coverage detected