@trpc/server 10.44.0 → 10.44.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchRequestHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/fetch/fetchRequestHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,MAAM,0BAA0B,CAAC,OAAO,SAAS,SAAS,IAC9D,mBAAmB,CAAC,OAAO,CAAC,GAAG;IAC7B,GAAG,EAAE,OAAO,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;
|
|
1
|
+
{"version":3,"file":"fetchRequestHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/fetch/fetchRequestHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,MAAM,0BAA0B,CAAC,OAAO,SAAS,SAAS,IAC9D,mBAAmB,CAAC,OAAO,CAAC,GAAG;IAC7B,GAAG,EAAE,OAAO,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AASJ,wBAAsB,mBAAmB,CAAC,OAAO,SAAS,SAAS,EACjE,IAAI,EAAE,0BAA0B,CAAC,OAAO,CAAC,GACxC,OAAO,CAAC,QAAQ,CAAC,CAuGnB"}
|
|
@@ -11,6 +11,11 @@ require('../../TRPCError-84cb03cf.js');
|
|
|
11
11
|
require('../../transformTRPCResponse-e65f34e9.js');
|
|
12
12
|
require('../../contentType-10776292.js');
|
|
13
13
|
|
|
14
|
+
const trimSlashes = (path)=>{
|
|
15
|
+
path = path.startsWith('/') ? path.slice(1) : path;
|
|
16
|
+
path = path.endsWith('/') ? path.slice(0, -1) : path;
|
|
17
|
+
return path;
|
|
18
|
+
};
|
|
14
19
|
async function fetchRequestHandler(opts) {
|
|
15
20
|
const resHeaders = new Headers();
|
|
16
21
|
const createContext = async ()=>{
|
|
@@ -20,7 +25,9 @@ async function fetchRequestHandler(opts) {
|
|
|
20
25
|
});
|
|
21
26
|
};
|
|
22
27
|
const url = new URL(opts.req.url);
|
|
23
|
-
const
|
|
28
|
+
const pathname = trimSlashes(url.pathname);
|
|
29
|
+
const endpoint = trimSlashes(opts.endpoint);
|
|
30
|
+
const path = trimSlashes(pathname.slice(endpoint.length));
|
|
24
31
|
const req = {
|
|
25
32
|
query: url.searchParams,
|
|
26
33
|
method: opts.req.method,
|
|
@@ -7,6 +7,11 @@ import '../../TRPCError-689e79f1.mjs';
|
|
|
7
7
|
import '../../transformTRPCResponse-1153b421.mjs';
|
|
8
8
|
import '../../contentType-778b33c3.mjs';
|
|
9
9
|
|
|
10
|
+
const trimSlashes = (path)=>{
|
|
11
|
+
path = path.startsWith('/') ? path.slice(1) : path;
|
|
12
|
+
path = path.endsWith('/') ? path.slice(0, -1) : path;
|
|
13
|
+
return path;
|
|
14
|
+
};
|
|
10
15
|
async function fetchRequestHandler(opts) {
|
|
11
16
|
const resHeaders = new Headers();
|
|
12
17
|
const createContext = async ()=>{
|
|
@@ -16,7 +21,9 @@ async function fetchRequestHandler(opts) {
|
|
|
16
21
|
});
|
|
17
22
|
};
|
|
18
23
|
const url = new URL(opts.req.url);
|
|
19
|
-
const
|
|
24
|
+
const pathname = trimSlashes(url.pathname);
|
|
25
|
+
const endpoint = trimSlashes(opts.endpoint);
|
|
26
|
+
const path = trimSlashes(pathname.slice(endpoint.length));
|
|
20
27
|
const req = {
|
|
21
28
|
query: url.searchParams,
|
|
22
29
|
method: opts.req.method,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/server",
|
|
3
|
-
"version": "10.44.
|
|
3
|
+
"version": "10.44.1",
|
|
4
4
|
"description": "The tRPC server library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -176,5 +176,5 @@
|
|
|
176
176
|
"funding": [
|
|
177
177
|
"https://trpc.io/sponsor"
|
|
178
178
|
],
|
|
179
|
-
"gitHead": "
|
|
179
|
+
"gitHead": "cd6a8ad0851522ef81028ff7c235ad9c203498e3"
|
|
180
180
|
}
|
|
@@ -10,6 +10,13 @@ export type FetchHandlerRequestOptions<TRouter extends AnyRouter> =
|
|
|
10
10
|
endpoint: string;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
+
const trimSlashes = (path: string): string => {
|
|
14
|
+
path = path.startsWith('/') ? path.slice(1) : path;
|
|
15
|
+
path = path.endsWith('/') ? path.slice(0, -1) : path;
|
|
16
|
+
|
|
17
|
+
return path;
|
|
18
|
+
};
|
|
19
|
+
|
|
13
20
|
export async function fetchRequestHandler<TRouter extends AnyRouter>(
|
|
14
21
|
opts: FetchHandlerRequestOptions<TRouter>,
|
|
15
22
|
): Promise<Response> {
|
|
@@ -20,9 +27,11 @@ export async function fetchRequestHandler<TRouter extends AnyRouter>(
|
|
|
20
27
|
};
|
|
21
28
|
|
|
22
29
|
const url = new URL(opts.req.url);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
);
|
|
30
|
+
|
|
31
|
+
const pathname = trimSlashes(url.pathname);
|
|
32
|
+
const endpoint = trimSlashes(opts.endpoint);
|
|
33
|
+
const path = trimSlashes(pathname.slice(endpoint.length));
|
|
34
|
+
|
|
26
35
|
const req: HTTPRequest = {
|
|
27
36
|
query: url.searchParams,
|
|
28
37
|
method: opts.req.method,
|