Spaces:
Running
Running
ling-open-studio / node_modules /next /dist /client /components /http-access-fallback /http-access-fallback.js
| ; | |
| Object.defineProperty(exports, "__esModule", { | |
| value: true | |
| }); | |
| 0 && (module.exports = { | |
| HTTPAccessErrorStatus: null, | |
| HTTP_ERROR_FALLBACK_ERROR_CODE: null, | |
| getAccessFallbackErrorTypeByStatus: null, | |
| getAccessFallbackHTTPStatus: null, | |
| isHTTPAccessFallbackError: null | |
| }); | |
| function _export(target, all) { | |
| for(var name in all)Object.defineProperty(target, name, { | |
| enumerable: true, | |
| get: all[name] | |
| }); | |
| } | |
| _export(exports, { | |
| HTTPAccessErrorStatus: function() { | |
| return HTTPAccessErrorStatus; | |
| }, | |
| HTTP_ERROR_FALLBACK_ERROR_CODE: function() { | |
| return HTTP_ERROR_FALLBACK_ERROR_CODE; | |
| }, | |
| getAccessFallbackErrorTypeByStatus: function() { | |
| return getAccessFallbackErrorTypeByStatus; | |
| }, | |
| getAccessFallbackHTTPStatus: function() { | |
| return getAccessFallbackHTTPStatus; | |
| }, | |
| isHTTPAccessFallbackError: function() { | |
| return isHTTPAccessFallbackError; | |
| } | |
| }); | |
| const HTTPAccessErrorStatus = { | |
| NOT_FOUND: 404, | |
| FORBIDDEN: 403, | |
| UNAUTHORIZED: 401 | |
| }; | |
| const ALLOWED_CODES = new Set(Object.values(HTTPAccessErrorStatus)); | |
| const HTTP_ERROR_FALLBACK_ERROR_CODE = 'NEXT_HTTP_ERROR_FALLBACK'; | |
| function isHTTPAccessFallbackError(error) { | |
| if (typeof error !== 'object' || error === null || !('digest' in error) || typeof error.digest !== 'string') { | |
| return false; | |
| } | |
| const [prefix, httpStatus] = error.digest.split(';'); | |
| return prefix === HTTP_ERROR_FALLBACK_ERROR_CODE && ALLOWED_CODES.has(Number(httpStatus)); | |
| } | |
| function getAccessFallbackHTTPStatus(error) { | |
| const httpStatus = error.digest.split(';')[1]; | |
| return Number(httpStatus); | |
| } | |
| function getAccessFallbackErrorTypeByStatus(status) { | |
| switch(status){ | |
| case 401: | |
| return 'unauthorized'; | |
| case 403: | |
| return 'forbidden'; | |
| case 404: | |
| return 'not-found'; | |
| default: | |
| return; | |
| } | |
| } | |
| if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') { | |
| Object.defineProperty(exports.default, '__esModule', { value: true }); | |
| Object.assign(exports.default, exports); | |
| module.exports = exports.default; | |
| } | |
| //# sourceMappingURL=http-access-fallback.js.map |