30 lines
643 B
Plaintext
30 lines
643 B
Plaintext
function redirect(opts) {
|
|
opts.isRedirect = true;
|
|
opts.statusCode = opts.statusCode || opts.code || 307;
|
|
opts.headers = opts.headers || {};
|
|
if (!opts.reloadDocument) {
|
|
opts.reloadDocument = false;
|
|
try {
|
|
new URL(`${opts.href}`);
|
|
opts.reloadDocument = true;
|
|
} catch {
|
|
}
|
|
}
|
|
if (opts.throw) {
|
|
throw opts;
|
|
}
|
|
return opts;
|
|
}
|
|
function isRedirect(obj) {
|
|
return !!(obj == null ? void 0 : obj.isRedirect);
|
|
}
|
|
function isResolvedRedirect(obj) {
|
|
return !!(obj == null ? void 0 : obj.isRedirect) && obj.href;
|
|
}
|
|
export {
|
|
isRedirect,
|
|
isResolvedRedirect,
|
|
redirect
|
|
};
|
|
//# sourceMappingURL=redirect.js.map
|