Next.js website for Rocky Mountain Vending company featuring: - Product catalog with Stripe integration - Service areas and parts pages - Admin dashboard with Clerk authentication - SEO optimized pages with JSON-LD structured data Co-authored-by: Cursor <cursoragent@cursor.com>
26 lines
No EOL
1.1 KiB
Text
26 lines
No EOL
1.1 KiB
Text
import { RedirectStatusCode } from './redirect-status-code';
|
|
export const REDIRECT_ERROR_CODE = 'NEXT_REDIRECT';
|
|
export var RedirectType = /*#__PURE__*/ function(RedirectType) {
|
|
RedirectType["push"] = "push";
|
|
RedirectType["replace"] = "replace";
|
|
return RedirectType;
|
|
}({});
|
|
/**
|
|
* Checks an error to determine if it's an error generated by the
|
|
* `redirect(url)` helper.
|
|
*
|
|
* @param error the error that may reference a redirect error
|
|
* @returns true if the error is a redirect error
|
|
*/ export function isRedirectError(error) {
|
|
if (typeof error !== 'object' || error === null || !('digest' in error) || typeof error.digest !== 'string') {
|
|
return false;
|
|
}
|
|
const digest = error.digest.split(';');
|
|
const [errorCode, type] = digest;
|
|
const destination = digest.slice(2, -2).join(';');
|
|
const status = digest.at(-2);
|
|
const statusCode = Number(status);
|
|
return errorCode === REDIRECT_ERROR_CODE && (type === 'replace' || type === 'push') && typeof destination === 'string' && !isNaN(statusCode) && statusCode in RedirectStatusCode;
|
|
}
|
|
|
|
//# sourceMappingURL=redirect-error.js.map |