MCPcopy Create free account
hub / github.com/dailydotdev/apps / getRedirectNextPath

Function getRedirectNextPath

packages/shared/src/lib/links.ts:178–198  ·  view source on GitHub ↗
(params: URLSearchParams)

Source from the content-addressed store, hash-verified

176};
177
178export const getRedirectNextPath = (params: URLSearchParams): string => {
179 const next = params.get('next');
180
181 let nextPath = '/';
182
183 if (next) {
184 try {
185 const nextUrl = new URL(next, 'http://localhost');
186 // infinite redirect loop prevention
187 nextUrl.searchParams.delete('next');
188
189 // we ignore url origin since we don't allow cross-origin redirects
190 nextPath = getPathnameWithQuery(nextUrl.pathname, nextUrl.searchParams);
191 } catch (error) {
192 // eslint-disable-next-line no-console
193 console.error(error);
194 }
195 }
196
197 return checkIsExtension() ? `${webappUrl}${nextPath}` : nextPath;
198};
199
200/* A function, not a constant: `webappUrl` comes from the environment, and a
201 module-level template literal captures it before a test can set it. */

Callers 2

CoresPaymentPageFunction · 0.90
CoresPageFunction · 0.90

Calls 3

checkIsExtensionFunction · 0.90
getPathnameWithQueryFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected