@astrojs/cloudflare 11.0.5 → 11.1.0
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.
|
@@ -96,6 +96,28 @@ class PathTrie {
|
|
|
96
96
|
this.dfs(childNode, [...path, segment], allPaths);
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* The reduce function is used to remove unnecessary paths from the trie.
|
|
101
|
+
* It receives a trie node to compare with the current node.
|
|
102
|
+
*/
|
|
103
|
+
reduce(compNode, node) {
|
|
104
|
+
if (node.hasWildcardChild || compNode.hasWildcardChild)
|
|
105
|
+
return;
|
|
106
|
+
for (const [segment, childNode] of node.children) {
|
|
107
|
+
if (childNode.children.size === 0)
|
|
108
|
+
continue;
|
|
109
|
+
const compChildNode = compNode.children.get(segment);
|
|
110
|
+
if (compChildNode === undefined) {
|
|
111
|
+
childNode.hasWildcardChild = true;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
this.reduce(compChildNode, childNode);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
reduceAllPaths(compTrie) {
|
|
118
|
+
this.reduce(compTrie.root, this.root);
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
99
121
|
getAllPaths() {
|
|
100
122
|
const allPaths = [];
|
|
101
123
|
this.dfs(this.root, [], allPaths);
|
|
@@ -181,7 +203,6 @@ export async function createRoutesFile(_config, logger, routes, pages, redirects
|
|
|
181
203
|
for (const includePath of includePaths) {
|
|
182
204
|
includeTrie.insert(includePath);
|
|
183
205
|
}
|
|
184
|
-
const [deduplicatedIncludePaths, includedPathsHaveWildcard] = includeTrie.getAllPaths();
|
|
185
206
|
const excludeTrie = new PathTrie();
|
|
186
207
|
for (const excludePath of excludePaths) {
|
|
187
208
|
/**
|
|
@@ -193,7 +214,12 @@ export async function createRoutesFile(_config, logger, routes, pages, redirects
|
|
|
193
214
|
continue;
|
|
194
215
|
excludeTrie.insert(excludePath);
|
|
195
216
|
}
|
|
196
|
-
const [
|
|
217
|
+
const [deduplicatedIncludePaths, includedPathsHaveWildcard] = includeTrie
|
|
218
|
+
.reduceAllPaths(excludeTrie)
|
|
219
|
+
.getAllPaths();
|
|
220
|
+
const [deduplicatedExcludePaths, _excludedPathsHaveWildcard] = excludeTrie
|
|
221
|
+
.reduceAllPaths(includeTrie)
|
|
222
|
+
.getAllPaths();
|
|
197
223
|
/**
|
|
198
224
|
* Cloudflare allows no more than 100 include/exclude rules combined
|
|
199
225
|
* https://developers.cloudflare.com/pages/functions/routing/#limits
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/cloudflare",
|
|
3
3
|
"description": "Deploy your site to Cloudflare Workers/Pages",
|
|
4
|
-
"version": "11.0
|
|
4
|
+
"version": "11.1.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"author": "withastro",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"rollup": "^4.21.3",
|
|
52
52
|
"strip-ansi": "^7.1.0",
|
|
53
53
|
"vite": "^5.4.6",
|
|
54
|
-
"
|
|
55
|
-
"
|
|
54
|
+
"astro-scripts": "0.0.14",
|
|
55
|
+
"@astrojs/test-utils": "0.0.1"
|
|
56
56
|
},
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"provenance": true
|