@speedkit/cli 4.25.0 → 4.25.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.
- package/CHANGELOG.md +7 -0
- package/README.md +1 -1
- package/dist/services/revalidate/revalidate-service.d.ts +8 -2
- package/dist/services/revalidate/revalidate-service.js +10 -2
- package/dist/services/revalidate/revalidate-service.spec.d.ts +1 -0
- package/dist/services/revalidate/revalidate-service.spec.js +31 -0
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [4.25.1](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.25.0...v4.25.1) (2026-09-08)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **revalidate:** stop prefix derivation at a character class ([82a9432](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/82a94327b35b49e0b3403e4caee88356850f4457))
|
|
7
|
+
|
|
1
8
|
# [4.25.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.24.2...v4.25.0) (2026-09-08)
|
|
2
9
|
|
|
3
10
|
|
package/README.md
CHANGED
|
@@ -6,8 +6,14 @@ import { RevalidateFilterInterface, RevalidateJobStatusInterface, RevalidatePrev
|
|
|
6
6
|
*
|
|
7
7
|
* This is the same text MongoDB turns into index bounds, so deriving the prefix
|
|
8
8
|
* here keeps the two in step: the caller states the pattern once, and the prefix
|
|
9
|
-
* cannot drift from it.
|
|
10
|
-
*
|
|
9
|
+
* cannot drift from it. The walk stops at the first metacharacter.
|
|
10
|
+
*
|
|
11
|
+
* An escape only counts as a literal when it escapes punctuation, so `\.` yields
|
|
12
|
+
* `.` and the host survives. An alphanumeric escape is a character class or a
|
|
13
|
+
* special instead — `\w`, `\d`, `\s`, `\b`, `\n`, a back-reference — and matches
|
|
14
|
+
* no single known character, so the walk has to stop there. Reading `\w` as the
|
|
15
|
+
* letter "w" would build a prefix that matches nothing, and the job would then
|
|
16
|
+
* report zero assets rather than an error.
|
|
11
17
|
*/
|
|
12
18
|
export declare function derivePrefix(pattern: string): string;
|
|
13
19
|
export declare class RevalidateService {
|
|
@@ -25,8 +25,14 @@ const REGEXP_METACHARACTERS = new Set([
|
|
|
25
25
|
*
|
|
26
26
|
* This is the same text MongoDB turns into index bounds, so deriving the prefix
|
|
27
27
|
* here keeps the two in step: the caller states the pattern once, and the prefix
|
|
28
|
-
* cannot drift from it.
|
|
29
|
-
*
|
|
28
|
+
* cannot drift from it. The walk stops at the first metacharacter.
|
|
29
|
+
*
|
|
30
|
+
* An escape only counts as a literal when it escapes punctuation, so `\.` yields
|
|
31
|
+
* `.` and the host survives. An alphanumeric escape is a character class or a
|
|
32
|
+
* special instead — `\w`, `\d`, `\s`, `\b`, `\n`, a back-reference — and matches
|
|
33
|
+
* no single known character, so the walk has to stop there. Reading `\w` as the
|
|
34
|
+
* letter "w" would build a prefix that matches nothing, and the job would then
|
|
35
|
+
* report zero assets rather than an error.
|
|
30
36
|
*/
|
|
31
37
|
export function derivePrefix(pattern) {
|
|
32
38
|
if (!pattern.startsWith("^")) {
|
|
@@ -39,6 +45,8 @@ export function derivePrefix(pattern) {
|
|
|
39
45
|
const escaped = pattern[index + 1];
|
|
40
46
|
if (escaped === undefined)
|
|
41
47
|
break;
|
|
48
|
+
if (/[A-Za-z0-9]/.test(escaped))
|
|
49
|
+
break;
|
|
42
50
|
prefix += escaped;
|
|
43
51
|
index++;
|
|
44
52
|
continue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { describe, it } from "mocha";
|
|
3
|
+
import { derivePrefix } from "./revalidate-service.js";
|
|
4
|
+
describe("derivePrefix", () => {
|
|
5
|
+
it("reads the literal head up to the first metacharacter", () => {
|
|
6
|
+
expect(derivePrefix("^https://www\\.example\\.com/en/.*-c1234$")).to.equal("https://www.example.com/en/");
|
|
7
|
+
});
|
|
8
|
+
it("keeps the head before a group, so a locale alternation still yields a prefix", () => {
|
|
9
|
+
expect(derivePrefix("^https://www\\.example\\.com/(?:en|de)/.*-c1234$")).to.equal("https://www.example.com/");
|
|
10
|
+
});
|
|
11
|
+
it("stops at a character class instead of reading it as a letter", () => {
|
|
12
|
+
// Reading `\w` as "w" would yield ".../w" — a prefix that matches nothing,
|
|
13
|
+
// which the job reports as zero assets rather than as an error.
|
|
14
|
+
expect(derivePrefix("^https://www\\.example\\.com/\\w{2}/.*-c1234$")).to.equal("https://www.example.com/");
|
|
15
|
+
expect(derivePrefix("^https://www\\.example\\.com/\\d+/")).to.equal("https://www.example.com/");
|
|
16
|
+
expect(derivePrefix("^https://www\\.example\\.com/\\s")).to.equal("https://www.example.com/");
|
|
17
|
+
});
|
|
18
|
+
it("treats an escaped punctuation character as a literal", () => {
|
|
19
|
+
expect(derivePrefix("^https://www\\.example\\.com/a\\-b/")).to.equal("https://www.example.com/a-b/");
|
|
20
|
+
});
|
|
21
|
+
it("yields nothing for an unanchored pattern", () => {
|
|
22
|
+
expect(derivePrefix("https://www\\.example\\.com/en/")).to.equal("");
|
|
23
|
+
expect(derivePrefix("-c1234$")).to.equal("");
|
|
24
|
+
});
|
|
25
|
+
it("yields nothing when a metacharacter follows the anchor", () => {
|
|
26
|
+
expect(derivePrefix("^(?:a|b)")).to.equal("");
|
|
27
|
+
});
|
|
28
|
+
it("does not run past a trailing backslash", () => {
|
|
29
|
+
expect(derivePrefix("^https://www\\.example\\.com/\\")).to.equal("https://www.example.com/");
|
|
30
|
+
});
|
|
31
|
+
});
|
package/oclif.manifest.json
CHANGED