@netlify/plugin-nextjs 4.41.3 → 5.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -17
- package/dist/build/cache.js +15 -0
- package/dist/build/content/prerendered.js +16 -0
- package/dist/build/content/server.js +18 -0
- package/dist/build/content/static.js +20 -0
- package/dist/build/functions/edge.js +14 -0
- package/dist/build/functions/server.js +16 -0
- package/dist/build/plugin-context.js +17 -0
- package/dist/esm-chunks/chunk-4AJYXTWN.js +17 -0
- package/dist/esm-chunks/chunk-5N2CWXSJ.js +564 -0
- package/dist/esm-chunks/chunk-A22224GM.js +113 -0
- package/dist/esm-chunks/chunk-AVWFCGVE.js +5536 -0
- package/dist/esm-chunks/chunk-B6QMRLBH.js +255 -0
- package/dist/esm-chunks/chunk-G3GM7JNF.js +92 -0
- package/dist/esm-chunks/chunk-GGHAQM5D.js +28 -0
- package/dist/esm-chunks/chunk-NOX2JUQZ.js +89 -0
- package/dist/esm-chunks/chunk-R4NHZWGU.js +32 -0
- package/dist/esm-chunks/chunk-RSKIKBZH.js +44 -0
- package/dist/esm-chunks/chunk-UXLNY5XK.js +86 -0
- package/dist/esm-chunks/chunk-VP3PT3VV.js +119 -0
- package/dist/esm-chunks/chunk-YZXA5QBC.js +60 -0
- package/dist/esm-chunks/chunk-Z7ZMLVTM.js +78 -0
- package/dist/index.js +66 -0
- package/dist/run/config.js +18 -0
- package/dist/run/constants.js +15 -0
- package/dist/run/handlers/cache.cjs +852 -0
- package/dist/run/handlers/server.js +3297 -0
- package/dist/run/headers.js +19 -0
- package/dist/run/next.cjs +1058 -0
- package/dist/run/revalidate.js +13 -0
- package/dist/run/systemlog.js +15 -0
- package/edge-runtime/README.md +29 -0
- package/edge-runtime/lib/headers.ts +26 -0
- package/edge-runtime/lib/middleware.ts +60 -0
- package/edge-runtime/lib/next-request.ts +59 -0
- package/edge-runtime/lib/response.ts +145 -0
- package/{src/templates/edge-shared/next-utils.ts → edge-runtime/lib/routing.ts} +64 -20
- package/edge-runtime/lib/util.ts +26 -0
- package/edge-runtime/middleware.ts +53 -0
- package/edge-runtime/shim/index.js +11 -0
- package/{src/templates → edge-runtime}/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/index.ts +1 -1
- package/edge-runtime/vendor/import_map.json +13 -0
- package/edge-runtime/vendor.ts +18 -0
- package/manifest.yml +1 -1
- package/package.json +23 -60
- package/index.js +0 -1
- package/lib/constants.js +0 -56
- package/lib/helpers/analysis.js +0 -115
- package/lib/helpers/cache.js +0 -46
- package/lib/helpers/compiler.js +0 -119
- package/lib/helpers/config.js +0 -192
- package/lib/helpers/dev.js +0 -20
- package/lib/helpers/edge.js +0 -328
- package/lib/helpers/files.js +0 -335
- package/lib/helpers/flags.js +0 -46
- package/lib/helpers/functions.js +0 -437
- package/lib/helpers/functionsMetaData.js +0 -46
- package/lib/helpers/matchers.js +0 -41
- package/lib/helpers/middlewareWatcher.js +0 -12
- package/lib/helpers/pack.js +0 -41
- package/lib/helpers/redirects.js +0 -246
- package/lib/helpers/types.js +0 -2
- package/lib/helpers/utils.js +0 -226
- package/lib/helpers/verification.js +0 -182
- package/lib/index.js +0 -194
- package/lib/templates/blobStorage.js +0 -30
- package/lib/templates/getApiHandler.js +0 -120
- package/lib/templates/getHandler.js +0 -201
- package/lib/templates/getPageResolver.js +0 -54
- package/lib/templates/handlerUtils.js +0 -268
- package/lib/templates/ipx.js +0 -13
- package/lib/templates/requireHooks.js +0 -105
- package/lib/templates/server.js +0 -159
- package/lib/templates/vendor.js +0 -20
- package/src/templates/edge/bundle.js +0 -8
- package/src/templates/edge/function-runtime.ts +0 -24
- package/src/templates/edge/imageconfig.json +0 -3
- package/src/templates/edge/ipx.ts +0 -5
- package/src/templates/edge/middleware-runtime.ts +0 -62
- package/src/templates/edge/next-dev.js +0 -104
- package/src/templates/edge/rsc-data.ts +0 -5
- package/src/templates/edge/shims.js +0 -77
- package/src/templates/edge-shared/nextConfig.json +0 -3
- package/src/templates/edge-shared/prerender-manifest.json +0 -7
- package/src/templates/edge-shared/rsc-data.ts +0 -78
- package/src/templates/edge-shared/utils.test.ts +0 -114
- package/src/templates/edge-shared/utils.ts +0 -315
- package/src/templates/vendor/import_map.json +0 -13
- /package/{src/templates/edge → edge-runtime}/matchers.json +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.134.0/fmt/colors.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.134.0/testing/_diff.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.134.0/testing/asserts.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/_util/asserts.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/_util/os.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/abortable.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/deadline.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/debounce.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/deferred.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/delay.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/mod.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/mux_async_iterator.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/pool.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/retry.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/tee.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/bytes/index_of_needle.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/crypto/timing_safe_equal.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/datetime/to_imf.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/encoding/base64.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/encoding/base64url.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/flags/mod.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/fmt/colors.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/fmt/printf.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/http/cookie.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_core.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_events.d.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_events.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_global.d.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_next_tick.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_process/exiting.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_process/process.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_process/stdio.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_process/streams.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_stream.d.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_stream.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_util/_util_callbackify.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_utils.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/assert.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/assertion_error.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/async_hooks.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/buffer.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/events.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/buffer.d.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/buffer.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/crypto/_keys.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/crypto/constants.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/error_codes.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/errors.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/fixed_queue.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/hide_stack_frames.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/net.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/normalize_encoding.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/options.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/primordials.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/process/per_thread.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/readline/callbacks.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/readline/utils.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/streams/destroy.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/streams/end-of-stream.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/streams/utils.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/util/comparisons.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/util/debuglog.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/util/inspect.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/util/types.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/util.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/validators.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/_libuv_winerror.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/_listen.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/_node.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/_timingSafeEqual.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/_utils.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/_winerror.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/ares.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/async_wrap.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/buffer.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/cares_wrap.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/config.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/connection_wrap.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/constants.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/contextify.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/credentials.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/crypto.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/errors.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/fs.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/fs_dir.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/fs_event_wrap.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/handle_wrap.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/heap_utils.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/http_parser.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/icu.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/inspector.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/js_stream.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/messaging.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/mod.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/module_wrap.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/native_module.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/natives.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/node_file.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/node_options.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/options.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/os.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/performance.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/pipe_wrap.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/process_methods.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/report.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/serdes.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/signal_wrap.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/spawn_sync.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/stream_wrap.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/string_decoder.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/symbols.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/task_queue.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/tcp_wrap.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/timers.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/tls_wrap.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/trace_events.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/tty_wrap.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/types.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/udp_wrap.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/url.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/util.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/uv.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/v8.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/worker.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/zlib.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/process.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/stream.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/string_decoder.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/util/types.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/util.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/_constants.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/_interface.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/_util.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/common.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/glob.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/mod.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/posix.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/separator.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/win32.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/streams/write_all.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/testing/_diff.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/testing/_format.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/testing/asserts.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/types.d.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/asyncify.js +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/html_rewriter.d.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/html_rewriter.js +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/x/path_to_regexp@v6.2.1/index.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/esm.sh/v91/next@12.2.5/deno/dist/compiled/cookie.js +0 -0
- /package/{src/templates → edge-runtime}/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/request.js +0 -0
- /package/{src/templates → edge-runtime}/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/response.js +0 -0
- /package/{src/templates → edge-runtime}/vendor/raw.githubusercontent.com/worker-tools/resolvable-promise/master/index.ts +0 -0
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import type { Context } from 'https://edge.netlify.com'
|
|
2
|
-
// Available at build time
|
|
3
|
-
import matchers from './matchers.json' assert { type: 'json' }
|
|
4
|
-
import edgeFunction from './bundle.js'
|
|
5
|
-
import { buildNextRequest, buildResponse } from '../edge-shared/utils.ts'
|
|
6
|
-
import { getMiddlewareRouteMatcher, MiddlewareRouteMatch, searchParamsToUrlQuery } from '../edge-shared/next-utils.ts'
|
|
7
|
-
import nextConfig from '../edge-shared/nextConfig.json' assert { type: 'json' }
|
|
8
|
-
|
|
9
|
-
const matchesMiddleware: MiddlewareRouteMatch = getMiddlewareRouteMatcher(matchers || [])
|
|
10
|
-
|
|
11
|
-
export interface RequestContext {
|
|
12
|
-
request: Request
|
|
13
|
-
context: Context
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
declare global {
|
|
17
|
-
// deno-lint-ignore no-var
|
|
18
|
-
var NFRequestContextMap: Map<string, RequestContext>
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
globalThis.NFRequestContextMap ||= new Map()
|
|
22
|
-
|
|
23
|
-
const handler = async (req: Request, context: Context) => {
|
|
24
|
-
if (Deno.env.get('NETLIFY_DEV')) {
|
|
25
|
-
// Don't run in dev
|
|
26
|
-
return
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const url = new URL(req.url)
|
|
30
|
-
|
|
31
|
-
// While we have already checked the path when mapping to the edge function,
|
|
32
|
-
// Next.js supports extra rules that we need to check here too.
|
|
33
|
-
if (!matchesMiddleware(url.pathname, req, searchParamsToUrlQuery(url.searchParams))) {
|
|
34
|
-
return
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const requestId = req.headers.get('x-nf-request-id')
|
|
38
|
-
if (!requestId) {
|
|
39
|
-
console.error('Missing x-nf-request-id header')
|
|
40
|
-
} else {
|
|
41
|
-
globalThis.NFRequestContextMap.set(requestId, {
|
|
42
|
-
request: req,
|
|
43
|
-
context,
|
|
44
|
-
})
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const request = buildNextRequest(req, context, nextConfig)
|
|
48
|
-
|
|
49
|
-
try {
|
|
50
|
-
const result = await edgeFunction({ request })
|
|
51
|
-
return buildResponse({ result, request: req, context })
|
|
52
|
-
} catch (error) {
|
|
53
|
-
console.error(error)
|
|
54
|
-
return new Response(error.message, { status: 500 })
|
|
55
|
-
} finally {
|
|
56
|
-
if (requestId) {
|
|
57
|
-
globalThis.NFRequestContextMap.delete(requestId)
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export default handler
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { NextRequest } from '../vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/request.js'
|
|
2
|
-
import { NextResponse } from '../vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/response.js'
|
|
3
|
-
import { fromFileUrl } from '../vendor/deno.land/std@0.175.0/path/mod.ts'
|
|
4
|
-
import { buildResponse, isFunction } from '../edge-shared/utils.ts'
|
|
5
|
-
|
|
6
|
-
globalThis.NFRequestContextMap ||= new Map()
|
|
7
|
-
globalThis.__dirname = fromFileUrl(new URL('./', import.meta.url)).slice(0, -1)
|
|
8
|
-
globalThis.process ||= { env: Deno.env.toObject() }
|
|
9
|
-
|
|
10
|
-
// Next.js uses this extension to the Headers API implemented by Cloudflare workerd
|
|
11
|
-
if (!('getAll' in Headers.prototype)) {
|
|
12
|
-
Headers.prototype.getAll = function getAll(name) {
|
|
13
|
-
name = name.toLowerCase()
|
|
14
|
-
if (name !== 'set-cookie') {
|
|
15
|
-
throw new Error('Headers.getAll is only supported for Set-Cookie')
|
|
16
|
-
}
|
|
17
|
-
return [...this.entries()].filter(([key]) => key === name).map(([, value]) => value)
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
let idx = 0
|
|
22
|
-
|
|
23
|
-
const handler = async (req, context) => {
|
|
24
|
-
if (!Deno.env.get('NETLIFY_DEV')) {
|
|
25
|
-
// Only run in dev
|
|
26
|
-
return
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
let middleware
|
|
30
|
-
// Dynamic imports and FS operations aren't allowed when deployed,
|
|
31
|
-
// but that's fine because this is only ever used locally.
|
|
32
|
-
// We don't want to just try importing and use that to test,
|
|
33
|
-
// because that would also throw if there's an error in the middleware,
|
|
34
|
-
// which we would want to surface not ignore.
|
|
35
|
-
try {
|
|
36
|
-
// We need to cache-bust the import because otherwise it will claim it
|
|
37
|
-
// doesn't exist if the user creates it after the server starts
|
|
38
|
-
const nextMiddleware = await import(`../../middleware.js#${++idx}`)
|
|
39
|
-
|
|
40
|
-
// The middleware file can export a named `middleware` export or a `default` export
|
|
41
|
-
middleware = isFunction(nextMiddleware.middleware)
|
|
42
|
-
? nextMiddleware.middleware
|
|
43
|
-
: isFunction(nextMiddleware.default)
|
|
44
|
-
? nextMiddleware.default
|
|
45
|
-
: undefined
|
|
46
|
-
|
|
47
|
-
if (!middleware) {
|
|
48
|
-
throw new Error('The middleware must export a `middleware` or a `default` function')
|
|
49
|
-
}
|
|
50
|
-
} catch (importError) {
|
|
51
|
-
if (importError.code === 'ERR_MODULE_NOT_FOUND' && importError.message.includes(`middleware.js`)) {
|
|
52
|
-
// No middleware, so we silently return
|
|
53
|
-
return
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
throw importError
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// This is the format expected by Next.js along with the timezone which we support.
|
|
60
|
-
const geo = {
|
|
61
|
-
country: context.geo.country?.code,
|
|
62
|
-
region: context.geo.subdivision?.code,
|
|
63
|
-
city: context.geo.city,
|
|
64
|
-
latitude: context.geo.latitude?.toString(),
|
|
65
|
-
longitude: context.geo.longitude?.toString(),
|
|
66
|
-
timezone: context.geo.timezone,
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// A default request id is fine locally
|
|
70
|
-
const requestId = req.headers.get('x-nf-request-id') || 'request-id'
|
|
71
|
-
|
|
72
|
-
globalThis.NFRequestContextMap.set(requestId, {
|
|
73
|
-
request: req,
|
|
74
|
-
context,
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
const request = {
|
|
78
|
-
headers: Object.fromEntries(req.headers.entries()),
|
|
79
|
-
geo,
|
|
80
|
-
method: req.method,
|
|
81
|
-
ip: context.ip,
|
|
82
|
-
body: req.body || undefined,
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const nextRequest = new NextRequest(req, request)
|
|
86
|
-
|
|
87
|
-
try {
|
|
88
|
-
const response = await middleware(nextRequest)
|
|
89
|
-
return buildResponse({
|
|
90
|
-
result: { response: response || NextResponse.next(), waitUntil: Promise.resolve() },
|
|
91
|
-
request: req,
|
|
92
|
-
context,
|
|
93
|
-
})
|
|
94
|
-
} catch (error) {
|
|
95
|
-
console.error(error)
|
|
96
|
-
return new Response(error.message, { status: 500 })
|
|
97
|
-
} finally {
|
|
98
|
-
if (requestId) {
|
|
99
|
-
globalThis.NFRequestContextMap.delete(requestId)
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export default handler
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import prerenderManifest from '../edge-shared/prerender-manifest.json' assert { type: 'json' }
|
|
2
|
-
import { getRscDataRouter, PrerenderManifest } from '../edge-shared/rsc-data.ts'
|
|
3
|
-
|
|
4
|
-
const handler = getRscDataRouter(prerenderManifest as PrerenderManifest)
|
|
5
|
-
export default handler
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
// deno-lint-ignore-file prefer-const no-unused-vars
|
|
3
|
-
import { decode as _base64Decode } from '../vendor/deno.land/std@0.175.0/encoding/base64.ts'
|
|
4
|
-
import BufferCompat from '../vendor/deno.land/std@0.175.0/node/buffer.ts'
|
|
5
|
-
import EventsCompat from '../vendor/deno.land/std@0.175.0/node/events.ts'
|
|
6
|
-
import AsyncHooksCompat from '../vendor/deno.land/std@0.175.0/node/async_hooks.ts'
|
|
7
|
-
import AssertCompat from '../vendor/deno.land/std@0.175.0/node/assert.ts'
|
|
8
|
-
import UtilCompat from '../vendor/deno.land/std@0.175.0/node/util.ts'
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* These are the shims, polyfills and other kludges to make Next.js work in standards-compliant runtime.
|
|
12
|
-
* This file isn't imported, but is instead inlined along with other chunks into the edge bundle.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
// Deno defines "window", but naughty libraries think this means it's a browser
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
delete globalThis.window
|
|
18
|
-
globalThis.process = {
|
|
19
|
-
env: { ...Deno.env.toObject(), NEXT_RUNTIME: 'edge', NEXT_PRIVATE_MINIMAL_MODE: '1' },
|
|
20
|
-
}
|
|
21
|
-
globalThis.EdgeRuntime = 'netlify-edge'
|
|
22
|
-
let _ENTRIES = {}
|
|
23
|
-
|
|
24
|
-
// Next.js expects this as a global
|
|
25
|
-
globalThis.AsyncLocalStorage = AsyncHooksCompat.AsyncLocalStorage
|
|
26
|
-
|
|
27
|
-
// Next.js uses this extension to the Headers API implemented by Cloudflare workerd
|
|
28
|
-
if (!('getAll' in Headers.prototype)) {
|
|
29
|
-
// @ts-ignore
|
|
30
|
-
Headers.prototype.getAll = function getAll(name) {
|
|
31
|
-
name = name.toLowerCase()
|
|
32
|
-
if (name !== 'set-cookie') {
|
|
33
|
-
throw new Error('Headers.getAll is only supported for Set-Cookie')
|
|
34
|
-
}
|
|
35
|
-
return [...this.entries()].filter(([key]) => key === name).map(([, value]) => value)
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
// Next uses blob: urls to refer to local assets, so we need to intercept these
|
|
39
|
-
const _fetch = globalThis.fetch
|
|
40
|
-
const fetch /* type {typeof globalThis.fetch} */ = async (url, init) => {
|
|
41
|
-
try {
|
|
42
|
-
if (url instanceof URL && url.href?.startsWith('blob:')) {
|
|
43
|
-
const key = url.href.slice(5)
|
|
44
|
-
if (key in _ASSETS) {
|
|
45
|
-
return new Response(_base64Decode(_ASSETS[key]))
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return await _fetch(url, init)
|
|
49
|
-
} catch (error) {
|
|
50
|
-
console.error(error)
|
|
51
|
-
throw error
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Shim native modules that Vercel makes available
|
|
56
|
-
if (typeof require === 'undefined') {
|
|
57
|
-
globalThis.require = (name) => {
|
|
58
|
-
switch (name.replace(/^node:/, '')) {
|
|
59
|
-
case 'buffer':
|
|
60
|
-
return BufferCompat
|
|
61
|
-
case 'events':
|
|
62
|
-
return EventsCompat
|
|
63
|
-
case 'async_hooks':
|
|
64
|
-
return AsyncHooksCompat
|
|
65
|
-
case 'assert':
|
|
66
|
-
return AssertCompat
|
|
67
|
-
case 'util':
|
|
68
|
-
return UtilCompat
|
|
69
|
-
default:
|
|
70
|
-
throw new ReferenceError(`Native module not found: ${name}`)
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Next edge runtime uses "self" as a function-scoped global-like object, but some of the older polyfills expect it to equal globalThis
|
|
76
|
-
// See https://nextjs.org/docs/basic-features/supported-browsers-features#polyfills
|
|
77
|
-
const self = { ...globalThis, fetch }
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import type { EdgeFunction } from 'https://edge.netlify.com'
|
|
2
|
-
|
|
3
|
-
// These are copied from next/dist/build. This file gets copied as part of the next
|
|
4
|
-
// runtime build and can't reference the next package directly.
|
|
5
|
-
//
|
|
6
|
-
// Latest types at https://github.com/vercel/next.js/blob/4a2df3c3752aeddc50fd5ab053440eccf71ae50b/packages/next/src/build/index.ts#L140
|
|
7
|
-
export declare type SsgRoute = {
|
|
8
|
-
initialRevalidateSeconds: number | false
|
|
9
|
-
srcRoute: string | null
|
|
10
|
-
dataRoute: string | null
|
|
11
|
-
}
|
|
12
|
-
export declare type DynamicSsgRoute = {
|
|
13
|
-
routeRegex: string
|
|
14
|
-
fallback: string | null | false
|
|
15
|
-
dataRoute: string | null
|
|
16
|
-
dataRouteRegex: string
|
|
17
|
-
}
|
|
18
|
-
export declare type PrerenderManifest = {
|
|
19
|
-
version: 3
|
|
20
|
-
routes: {
|
|
21
|
-
[route: string]: SsgRoute
|
|
22
|
-
}
|
|
23
|
-
dynamicRoutes: {
|
|
24
|
-
[route: string]: DynamicSsgRoute
|
|
25
|
-
}
|
|
26
|
-
notFoundRoutes: string[]
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const noop = () => {}
|
|
30
|
-
|
|
31
|
-
// Ensure that routes with and without a trailing slash map to different ODB paths
|
|
32
|
-
const rscifyPath = (route: string) => {
|
|
33
|
-
if (route.endsWith('/')) {
|
|
34
|
-
return route.slice(0, -1) + '.rsc/'
|
|
35
|
-
}
|
|
36
|
-
return route + '.rsc'
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const getRscDataRouter = ({ routes: staticRoutes, dynamicRoutes }: PrerenderManifest): EdgeFunction => {
|
|
40
|
-
const staticRouteSet = new Set(
|
|
41
|
-
Object.entries(staticRoutes)
|
|
42
|
-
.filter(([, { dataRoute }]) => dataRoute?.endsWith('.rsc'))
|
|
43
|
-
.map(([route]) => route),
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
const dynamicRouteMatcher = Object.values(dynamicRoutes)
|
|
47
|
-
.filter(({ dataRoute }) => dataRoute?.endsWith('.rsc'))
|
|
48
|
-
.map(({ routeRegex }) => new RegExp(routeRegex))
|
|
49
|
-
|
|
50
|
-
const matchesDynamicRscDataRoute = (pathname: string) => {
|
|
51
|
-
return dynamicRouteMatcher.some((matcher) => matcher.test(pathname))
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const matchesStaticRscDataRoute = (pathname: string) => {
|
|
55
|
-
const key = pathname.endsWith('/') ? pathname.slice(0, -1) : pathname
|
|
56
|
-
return staticRouteSet.has(key)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const matchesRscRoute = (pathname: string) => {
|
|
60
|
-
return matchesStaticRscDataRoute(pathname) || matchesDynamicRscDataRoute(pathname)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return (request, context) => {
|
|
64
|
-
const debug = request.headers.has('x-next-debug-logging')
|
|
65
|
-
const log = debug ? (...args: unknown[]) => console.log(...args) : noop
|
|
66
|
-
const url = new URL(request.url)
|
|
67
|
-
// If this is a static RSC request, rewrite to the data route
|
|
68
|
-
if (request.headers.get('rsc') === '1') {
|
|
69
|
-
log('Is rsc request')
|
|
70
|
-
if (matchesRscRoute(url.pathname)) {
|
|
71
|
-
request.headers.set('x-rsc-route', url.pathname)
|
|
72
|
-
const target = rscifyPath(url.pathname)
|
|
73
|
-
log('Rewriting to', target)
|
|
74
|
-
return context.rewrite(target)
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { assertEquals } from 'https://deno.land/std@0.167.0/testing/asserts.ts'
|
|
2
|
-
import { beforeEach, describe, it } from 'https://deno.land/std@0.167.0/testing/bdd.ts'
|
|
3
|
-
import { redirectTrailingSlash, updateModifiedHeaders } from './utils.ts'
|
|
4
|
-
|
|
5
|
-
describe('updateModifiedHeaders', () => {
|
|
6
|
-
it("does not modify the headers if 'x-middleware-override-headers' is not found", () => {
|
|
7
|
-
const mockHeaders = new Headers()
|
|
8
|
-
// There shouldn't be a case where x-middleware-override-headers is not set and a header has
|
|
9
|
-
// been modified with 'x-middleware-request' added to it, this is more to confirm the test case
|
|
10
|
-
mockHeaders.set('x-middleware-request-foo', 'bar')
|
|
11
|
-
|
|
12
|
-
const mockResponse = {
|
|
13
|
-
headers: mockHeaders,
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const mockRequest = {
|
|
17
|
-
headers: new Headers(),
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
updateModifiedHeaders(mockRequest.headers, mockResponse.headers)
|
|
21
|
-
|
|
22
|
-
assertEquals(mockRequest.headers.get('x-middleware-request-foo'), null)
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
describe("when the 'x-middleware-override-headers' headers is present", () => {
|
|
26
|
-
let mockHeaders
|
|
27
|
-
let mockRequest: { headers: Headers }
|
|
28
|
-
let mockResponse: { headers: Headers }
|
|
29
|
-
|
|
30
|
-
beforeEach(() => {
|
|
31
|
-
mockHeaders = new Headers()
|
|
32
|
-
mockHeaders.set('foo', 'bar')
|
|
33
|
-
mockHeaders.set('x-middleware-request-hello', 'world')
|
|
34
|
-
mockHeaders.set('x-middleware-request-test', '123')
|
|
35
|
-
mockHeaders.set('x-middleware-override-headers', 'hello,test')
|
|
36
|
-
|
|
37
|
-
mockRequest = {
|
|
38
|
-
headers: new Headers(),
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
mockResponse = {
|
|
42
|
-
headers: mockHeaders,
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
updateModifiedHeaders(mockRequest.headers, mockResponse.headers)
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
it("does not modify or add headers that are missing 'x-middleware-request' in the name", () => {
|
|
49
|
-
assertEquals(mockRequest.headers.get('foo'), null)
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
it("removes 'x-middleware-request-' from headers", () => {
|
|
53
|
-
assertEquals(mockRequest.headers.get('x-middleware-request-hello'), null)
|
|
54
|
-
assertEquals(mockRequest.headers.get('x-middleware-request-test'), null)
|
|
55
|
-
|
|
56
|
-
assertEquals(mockRequest.headers.get('hello'), 'world')
|
|
57
|
-
assertEquals(mockRequest.headers.get('test'), '123')
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
it("removes 'x-middleware-override-headers' after cleaning headers", () => {
|
|
61
|
-
assertEquals(mockRequest.headers.get('x-middleware-override-headers'), null)
|
|
62
|
-
})
|
|
63
|
-
})
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
describe('trailing slash redirects', () => {
|
|
67
|
-
it('adds a trailing slash to the pathn if trailingSlash is enabled', () => {
|
|
68
|
-
const url = new URL('https://example.com/foo')
|
|
69
|
-
const result = redirectTrailingSlash(url, true)
|
|
70
|
-
assertEquals(result?.status, 308)
|
|
71
|
-
assertEquals(result?.headers.get('location'), 'https://example.com/foo/')
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
it("doesn't add a trailing slash if trailingSlash is false", () => {
|
|
75
|
-
const url = new URL('https://example.com/foo')
|
|
76
|
-
const result = redirectTrailingSlash(url, false)
|
|
77
|
-
assertEquals(result, undefined)
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
it("doesn't add a trailing slash if the path is a file", () => {
|
|
81
|
-
const url = new URL('https://example.com/foo.txt')
|
|
82
|
-
const result = redirectTrailingSlash(url, true)
|
|
83
|
-
assertEquals(result, undefined)
|
|
84
|
-
})
|
|
85
|
-
it('adds a trailing slash if there is a dot in the path', () => {
|
|
86
|
-
const url = new URL('https://example.com/foo.bar/baz')
|
|
87
|
-
const result = redirectTrailingSlash(url, true)
|
|
88
|
-
assertEquals(result?.status, 308)
|
|
89
|
-
assertEquals(result?.headers.get('location'), 'https://example.com/foo.bar/baz/')
|
|
90
|
-
})
|
|
91
|
-
it("doesn't add a trailing slash if the path is /", () => {
|
|
92
|
-
const url = new URL('https://example.com/')
|
|
93
|
-
const result = redirectTrailingSlash(url, true)
|
|
94
|
-
assertEquals(result, undefined)
|
|
95
|
-
})
|
|
96
|
-
it('removes a trailing slash from the path if trailingSlash is false', () => {
|
|
97
|
-
const url = new URL('https://example.com/foo/')
|
|
98
|
-
const result = redirectTrailingSlash(url, false)
|
|
99
|
-
assertEquals(result?.status, 308)
|
|
100
|
-
assertEquals(result?.headers.get('location'), 'https://example.com/foo')
|
|
101
|
-
})
|
|
102
|
-
it("doesn't remove a trailing slash if trailingSlash is true", () => {
|
|
103
|
-
const url = new URL('https://example.com/foo/')
|
|
104
|
-
const result = redirectTrailingSlash(url, true)
|
|
105
|
-
assertEquals(result, undefined)
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
it('removes a trailing slash from the path if the path is a file', () => {
|
|
109
|
-
const url = new URL('https://example.com/foo.txt/')
|
|
110
|
-
const result = redirectTrailingSlash(url, false)
|
|
111
|
-
assertEquals(result?.status, 308)
|
|
112
|
-
assertEquals(result?.headers.get('location'), 'https://example.com/foo.txt')
|
|
113
|
-
})
|
|
114
|
-
})
|