(params: URLSearchParams)
| 166 | }; |
| 167 | |
| 168 | export const getRedirectNextPath = (params: URLSearchParams): string => { |
| 169 | const next = params.get('next'); |
| 170 | |
| 171 | let nextPath = '/'; |
| 172 | |
| 173 | if (next) { |
| 174 | try { |
| 175 | const nextUrl = new URL(next, 'http://localhost'); |
| 176 | // infinite redirect loop prevention |
| 177 | nextUrl.searchParams.delete('next'); |
| 178 | |
| 179 | // we ignore url origin since we don't allow cross-origin redirects |
| 180 | nextPath = getPathnameWithQuery(nextUrl.pathname, nextUrl.searchParams); |
| 181 | } catch (error) { |
| 182 | // eslint-disable-next-line no-console |
| 183 | console.error(error); |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | return checkIsExtension() ? `${webappUrl}${nextPath}` : nextPath; |
| 188 | }; |
no test coverage detected