@middy/http-cors 7.6.3 → 7.6.4
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/index.js +10 -0
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -51,8 +51,18 @@ const hostnameToPunycode = (hostname) => {
|
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
+
// ASCII (no IDN), no port-stripping needed, no `*` wildcard. Hot path: most
|
|
55
|
+
// Origin headers in production are plain ASCII URLs that this matches.
|
|
56
|
+
const asciiOriginFast = /^https?:\/\/[a-z0-9.-]+(?::\d+)?$/i;
|
|
57
|
+
|
|
54
58
|
const originToPunycode = (origin) => {
|
|
55
59
|
if (!origin || origin === "*") return origin;
|
|
60
|
+
// Fast-path: ASCII origin without wildcard — just canonicalize case.
|
|
61
|
+
// `new URL().host` lowercases the host portion; reproduce that here.
|
|
62
|
+
if (asciiOriginFast.test(origin)) {
|
|
63
|
+
// Lowercase only the scheme+host portion (which is all of it for this regex).
|
|
64
|
+
return origin.toLowerCase();
|
|
65
|
+
}
|
|
56
66
|
const match = origin.match(/^(https?:\/\/)(.+)$/);
|
|
57
67
|
if (!match) return origin;
|
|
58
68
|
const [, protocol, host] = match;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/http-cors",
|
|
3
|
-
"version": "7.6.
|
|
3
|
+
"version": "7.6.4",
|
|
4
4
|
"description": "CORS (Cross-Origin Resource Sharing) middleware for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
"url": "https://github.com/sponsors/willfarrell"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@middy/util": "7.6.
|
|
64
|
+
"@middy/util": "7.6.4"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@middy/core": "7.6.
|
|
67
|
+
"@middy/core": "7.6.4",
|
|
68
68
|
"@types/aws-lambda": "^8.0.0",
|
|
69
69
|
"@types/node": "^22.0.0"
|
|
70
70
|
}
|