next-md-negotiate 1.1.2 → 1.1.3
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/dist/index.cjs +1 -1
- package/dist/index.d.cts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -94,7 +94,7 @@ function matchPath(pattern, path) {
|
|
|
94
94
|
function createMdHandler(registry) {
|
|
95
95
|
return async function GET(_req, { params }) {
|
|
96
96
|
const { path } = await params;
|
|
97
|
-
const incomingPath = "/" + path.join("/");
|
|
97
|
+
const incomingPath = "/" + (path ?? []).join("/");
|
|
98
98
|
for (const route of registry) {
|
|
99
99
|
const match = matchPath(route.pattern, incomingPath);
|
|
100
100
|
if (match) {
|
package/dist/index.d.cts
CHANGED
|
@@ -38,10 +38,14 @@ interface MdVersionOptions {
|
|
|
38
38
|
declare function createMdVersion<T extends string>(pattern: T, handler: (params: ExtractParams<T>) => Promise<string>, options?: MdVersionOptions): MdVersionHandler;
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
|
-
* Creates a Next.js route handler for the
|
|
41
|
+
* Creates a Next.js route handler for the `/md-api/[[...path]]` route.
|
|
42
|
+
*
|
|
43
|
+
* Supports both `[...path]` (required catch-all) and `[[...path]]`
|
|
44
|
+
* (optional catch-all). The optional variant is needed to handle
|
|
45
|
+
* the root `/` route, where `path` will be `undefined`.
|
|
42
46
|
*
|
|
43
47
|
* @example
|
|
44
|
-
* // app/md-api/[...path]/route.ts
|
|
48
|
+
* // app/md-api/[[...path]]/route.ts
|
|
45
49
|
* import { createMdHandler } from 'next-md-negotiate';
|
|
46
50
|
* import registry from '@/md.config';
|
|
47
51
|
*
|
|
@@ -49,7 +53,7 @@ declare function createMdVersion<T extends string>(pattern: T, handler: (params:
|
|
|
49
53
|
*/
|
|
50
54
|
declare function createMdHandler(registry: MdVersionHandler[]): (req: Request, ctx: {
|
|
51
55
|
params: Promise<{
|
|
52
|
-
path
|
|
56
|
+
path?: string[];
|
|
53
57
|
}>;
|
|
54
58
|
}) => Promise<Response>;
|
|
55
59
|
|
package/dist/index.d.ts
CHANGED
|
@@ -38,10 +38,14 @@ interface MdVersionOptions {
|
|
|
38
38
|
declare function createMdVersion<T extends string>(pattern: T, handler: (params: ExtractParams<T>) => Promise<string>, options?: MdVersionOptions): MdVersionHandler;
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
|
-
* Creates a Next.js route handler for the
|
|
41
|
+
* Creates a Next.js route handler for the `/md-api/[[...path]]` route.
|
|
42
|
+
*
|
|
43
|
+
* Supports both `[...path]` (required catch-all) and `[[...path]]`
|
|
44
|
+
* (optional catch-all). The optional variant is needed to handle
|
|
45
|
+
* the root `/` route, where `path` will be `undefined`.
|
|
42
46
|
*
|
|
43
47
|
* @example
|
|
44
|
-
* // app/md-api/[...path]/route.ts
|
|
48
|
+
* // app/md-api/[[...path]]/route.ts
|
|
45
49
|
* import { createMdHandler } from 'next-md-negotiate';
|
|
46
50
|
* import registry from '@/md.config';
|
|
47
51
|
*
|
|
@@ -49,7 +53,7 @@ declare function createMdVersion<T extends string>(pattern: T, handler: (params:
|
|
|
49
53
|
*/
|
|
50
54
|
declare function createMdHandler(registry: MdVersionHandler[]): (req: Request, ctx: {
|
|
51
55
|
params: Promise<{
|
|
52
|
-
path
|
|
56
|
+
path?: string[];
|
|
53
57
|
}>;
|
|
54
58
|
}) => Promise<Response>;
|
|
55
59
|
|
package/dist/index.js
CHANGED
|
@@ -61,7 +61,7 @@ function matchPath(pattern, path) {
|
|
|
61
61
|
function createMdHandler(registry) {
|
|
62
62
|
return async function GET(_req, { params }) {
|
|
63
63
|
const { path } = await params;
|
|
64
|
-
const incomingPath = "/" + path.join("/");
|
|
64
|
+
const incomingPath = "/" + (path ?? []).join("/");
|
|
65
65
|
for (const route of registry) {
|
|
66
66
|
const match = matchPath(route.pattern, incomingPath);
|
|
67
67
|
if (match) {
|