File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -302,6 +302,13 @@ body {{
302
302
html = html.replace(/##\[warning\]/g, () =>
303
303
`<span class="warning-marker">##[warning]</span>`
304
304
);
305
+
306
+ // pre-5. Polyfill the recently (2025) added `RegExp.escape` function.
307
+ // Inspired by the former MDN section on escaping:
308
+ // https://web.archive.org/web/20230806114646/https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions#escaping
309
+ const escapeRegExp = RegExp.escape || function(string) {{
310
+ return string.replace(/[.*+?^${{}}()|[\]\\/]/g, "\\$&");
311
+ }};
305
312
306
313
// 5. Add anchors around some paths
307
314
// Detailed examples of what the regex does is at https://regex101.com/r/vCnx9Y/2
@@ -319,7 +326,7 @@ body {{
319
326
const pathRegex = new RegExp(
320
327
"(?<boundary_start>[^a-zA-Z0-9.\\/])"
321
328
+ "(?<inner>(?:[\\\/]?(?:checkout[\\\/])?(?<path>(?:"
322
- + tree_roots.map(p => RegExp.escape (p)).join("|")
329
+ + tree_roots.map(p => escapeRegExp (p)).join("|")
323
330
+ ")(?:[\\\/][a-zA-Z0-9_$\\\-.\\\/]+)?))"
324
331
+ "(?::(?<line>[0-9]+):(?<col>[0-9]+))?)(?<boundary_end>[^a-zA-Z0-9.])",
325
332
"g"
You can’t perform that action at this time.
0 commit comments