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 {{
302302 html = html.replace(/##\[warning\]/g, () =>
303303 `<span class="warning-marker">##[warning]</span>`
304304 );
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+ }};
305312
306313 // 5. Add anchors around some paths
307314 // Detailed examples of what the regex does is at https://regex101.com/r/vCnx9Y/2
@@ -319,7 +326,7 @@ body {{
319326 const pathRegex = new RegExp(
320327 "(?<boundary_start>[^a-zA-Z0-9.\\/])"
321328 + "(?<inner>(?:[\\\/]?(?:checkout[\\\/])?(?<path>(?:"
322- + tree_roots.map(p => RegExp.escape (p)).join("|")
329+ + tree_roots.map(p => escapeRegExp (p)).join("|")
323330 + ")(?:[\\\/][a-zA-Z0-9_$\\\-.\\\/]+)?))"
324331 + "(?::(?<line>[0-9]+):(?<col>[0-9]+))?)(?<boundary_end>[^a-zA-Z0-9.])",
325332 "g"
You can’t perform that action at this time.
0 commit comments