Skip to content

Commit 0841637

Browse files
committed
test: allow underscores in hash for server routes preload links
Updates the regular expressions in server-routes-preload-links.ts to allow underscores in the generated file hashes (changing [a-zA-Z0-9]{8} to [a-zA-Z0-9_]{8}). This ensures that the test correctly identifies modulepreload links when the hash contains an underscore, preventing failures due to overly strict matching.
1 parent b5ba365 commit 0841637

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

tests/e2e/tests/build/server-rendering/server-routes-preload-links.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export default async function () {
132132

133133
const res = await fetch(`http://localhost:${defaultServerPort}/`);
134134
const text = await res.text();
135-
const homeMatch = /<link rel="modulepreload" href="(home-[a-zA-Z0-9]{8}\.js)">/;
135+
const homeMatch = /<link rel="modulepreload" href="(home-[a-zA-Z0-9_]{8}\.js)">/;
136136
assert.match(text, homeMatch, `Response for '/': ${homeMatch} was not matched in content.`);
137137

138138
const link = text.match(homeMatch)?.[1];
@@ -148,36 +148,36 @@ const RESPONSE_EXPECTS: Record<
148148
}
149149
> = {
150150
'/': {
151-
matches: [/<link rel="modulepreload" href="(home-[a-zA-Z0-9]{8}\.js)">/],
151+
matches: [/<link rel="modulepreload" href="(home-[a-zA-Z0-9_]{8}\.js)">/],
152152
notMatches: [/ssg\-component/, /ssr/, /csr/, /cross-dep-/],
153153
},
154154
'/ssg': {
155155
matches: [
156-
/<link rel="modulepreload" href="(ssg\.routes-[a-zA-Z0-9]{8}\.js)">/,
157-
/<link rel="modulepreload" href="(ssg-component-[a-zA-Z0-9]{8}\.js)">/,
156+
/<link rel="modulepreload" href="(ssg\.routes-[a-zA-Z0-9_]{8}\.js)">/,
157+
/<link rel="modulepreload" href="(ssg-component-[a-zA-Z0-9_]{8}\.js)">/,
158158
],
159159
notMatches: [/home/, /ssr/, /csr/, /ssg-one/, /ssg-two/, /cross-dep-/],
160160
},
161161
'/ssg/one': {
162162
matches: [
163-
/<link rel="modulepreload" href="(ssg\.routes-[a-zA-Z0-9]{8}\.js)">/,
164-
/<link rel="modulepreload" href="(ssg-one-[a-zA-Z0-9]{8}\.js)">/,
163+
/<link rel="modulepreload" href="(ssg\.routes-[a-zA-Z0-9_]{8}\.js)">/,
164+
/<link rel="modulepreload" href="(ssg-one-[a-zA-Z0-9_]{8}\.js)">/,
165165
],
166166
notMatches: [/home/, /ssr/, /csr/, /ssg-two/, /ssg\-component/, /cross-dep-/],
167167
},
168168
'/ssg/two': {
169169
matches: [
170-
/<link rel="modulepreload" href="(ssg\.routes-[a-zA-Z0-9]{8}\.js)">/,
171-
/<link rel="modulepreload" href="(ssg-two-[a-zA-Z0-9]{8}\.js)">/,
170+
/<link rel="modulepreload" href="(ssg\.routes-[a-zA-Z0-9_]{8}\.js)">/,
171+
/<link rel="modulepreload" href="(ssg-two-[a-zA-Z0-9_]{8}\.js)">/,
172172
],
173173
notMatches: [/home/, /ssr/, /csr/, /ssg-one/, /ssg\-component/, /cross-dep-/],
174174
},
175175
'/ssr': {
176-
matches: [/<link rel="modulepreload" href="(ssr-[a-zA-Z0-9]{8}\.js)">/],
176+
matches: [/<link rel="modulepreload" href="(ssr-[a-zA-Z0-9_]{8}\.js)">/],
177177
notMatches: [/home/, /ssg\-component/, /csr/],
178178
},
179179
'/csr': {
180-
matches: [/<link rel="modulepreload" href="(csr-[a-zA-Z0-9]{8}\.js)">/],
180+
matches: [/<link rel="modulepreload" href="(csr-[a-zA-Z0-9_]{8}\.js)">/],
181181
notMatches: [/home/, /ssg\-component/, /ssr/, /cross-dep-/],
182182
},
183183
};

0 commit comments

Comments
 (0)