hono 4.8.4 → 4.8.5
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.
|
@@ -32,13 +32,23 @@ const ENCODINGS = {
|
|
|
32
32
|
const ENCODINGS_ORDERED_KEYS = Object.keys(ENCODINGS);
|
|
33
33
|
const DEFAULT_DOCUMENT = "index.html";
|
|
34
34
|
const defaultPathResolve = (path) => path;
|
|
35
|
+
const isAbsolutePath = (path) => {
|
|
36
|
+
const isUnixAbsolutePath = path.startsWith("/");
|
|
37
|
+
const hasDriveLetter = /^[a-zA-Z]:\\/.test(path);
|
|
38
|
+
const isUncPath = /^\\\\[^\\]+\\[^\\]+/.test(path);
|
|
39
|
+
return isUnixAbsolutePath || hasDriveLetter || isUncPath;
|
|
40
|
+
};
|
|
41
|
+
const windowsPathToUnixPath = (path) => {
|
|
42
|
+
return path.replace(/^[a-zA-Z]:/, "").replace(/\\/g, "/");
|
|
43
|
+
};
|
|
35
44
|
const serveStatic = (options) => {
|
|
36
45
|
let isAbsoluteRoot = false;
|
|
37
46
|
let root;
|
|
38
47
|
if (options.root) {
|
|
39
|
-
if (options.root
|
|
48
|
+
if (isAbsolutePath(options.root)) {
|
|
40
49
|
isAbsoluteRoot = true;
|
|
41
|
-
root =
|
|
50
|
+
root = windowsPathToUnixPath(options.root);
|
|
51
|
+
root = new URL(`file://${root}`).pathname;
|
|
42
52
|
} else {
|
|
43
53
|
root = options.root;
|
|
44
54
|
}
|
|
@@ -10,13 +10,23 @@ var ENCODINGS = {
|
|
|
10
10
|
var ENCODINGS_ORDERED_KEYS = Object.keys(ENCODINGS);
|
|
11
11
|
var DEFAULT_DOCUMENT = "index.html";
|
|
12
12
|
var defaultPathResolve = (path) => path;
|
|
13
|
+
var isAbsolutePath = (path) => {
|
|
14
|
+
const isUnixAbsolutePath = path.startsWith("/");
|
|
15
|
+
const hasDriveLetter = /^[a-zA-Z]:\\/.test(path);
|
|
16
|
+
const isUncPath = /^\\\\[^\\]+\\[^\\]+/.test(path);
|
|
17
|
+
return isUnixAbsolutePath || hasDriveLetter || isUncPath;
|
|
18
|
+
};
|
|
19
|
+
var windowsPathToUnixPath = (path) => {
|
|
20
|
+
return path.replace(/^[a-zA-Z]:/, "").replace(/\\/g, "/");
|
|
21
|
+
};
|
|
13
22
|
var serveStatic = (options) => {
|
|
14
23
|
let isAbsoluteRoot = false;
|
|
15
24
|
let root;
|
|
16
25
|
if (options.root) {
|
|
17
|
-
if (options.root
|
|
26
|
+
if (isAbsolutePath(options.root)) {
|
|
18
27
|
isAbsoluteRoot = true;
|
|
19
|
-
root =
|
|
28
|
+
root = windowsPathToUnixPath(options.root);
|
|
29
|
+
root = new URL(`file://${root}`).pathname;
|
|
20
30
|
} else {
|
|
21
31
|
root = options.root;
|
|
22
32
|
}
|
|
@@ -6,7 +6,7 @@ import type { Context } from '../../context';
|
|
|
6
6
|
export type Runtime = "node" | "deno" | "bun" | "workerd" | "fastly" | "edge-light" | "other";
|
|
7
7
|
export declare const env: <T extends Record<string, unknown>, C extends Context = Context<{
|
|
8
8
|
Bindings: T;
|
|
9
|
-
}
|
|
9
|
+
}>>(c: T extends Record<string, unknown> ? Context : C, runtime?: Runtime) => T & C["env"];
|
|
10
10
|
export declare const knownUserAgents: Partial<Record<Runtime, string>>;
|
|
11
11
|
export declare const getRuntimeKey: () => Runtime;
|
|
12
12
|
export declare const checkUserAgentEquals: (platform: string) => boolean;
|
package/dist/types/request.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GET_MATCH_RESULT } from './request/constants';
|
|
1
2
|
import type { Result } from './router';
|
|
2
3
|
import type { Input, InputToDataByTarget, ParamKeyToRecord, ParamKeys, RemoveQuestion, RouterRoute, ValidationTargets } from './types';
|
|
3
4
|
import type { BodyData, ParseBodyOptions } from './utils/body';
|
|
@@ -14,6 +15,10 @@ type BodyCache = Partial<Body & {
|
|
|
14
15
|
parsedBody: BodyData;
|
|
15
16
|
}>;
|
|
16
17
|
export declare class HonoRequest<P extends string = "/", I extends Input["out"] = {}> {
|
|
18
|
+
[GET_MATCH_RESULT]: Result<[
|
|
19
|
+
unknown,
|
|
20
|
+
RouterRoute
|
|
21
|
+
]>;
|
|
17
22
|
/**
|
|
18
23
|
* `.raw` can get the raw Request object.
|
|
19
24
|
*
|