Skip to content

Commit 4c371f1

Browse files
authored
Merge pull request #2131 from Urgau/gha_logs-boundary-end
Also verify that the end boundary isn't path-like
2 parents 96d377f + 090d695 commit 4c371f1

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/gha_logs.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,14 +335,16 @@ body {{
335335
//
336336
// Any other paths, in particular if prefixed by `./` or `obj/` should not taken.
337337
const pathRegex = new RegExp(
338-
"(?<boundary>[^a-zA-Z0-9.\\/])(?<inner>(?:[\\\/]?(?:checkout[\\\/])?(?<path>(?:"
339-
+ tree_roots.map(p => RegExp.escape(p)).join("|") +
340-
")(?:[\\\/][a-zA-Z0-9_$\\\-.\\\/]+)?))(?::(?<line>[0-9]+):(?<col>[0-9]+))?)",
338+
"(?<boundary_start>[^a-zA-Z0-9.\\/])"
339+
+ "(?<inner>(?:[\\\/]?(?:checkout[\\\/])?(?<path>(?:"
340+
+ tree_roots.map(p => RegExp.escape(p)).join("|")
341+
+ ")(?:[\\\/][a-zA-Z0-9_$\\\-.\\\/]+)?))"
342+
+ "(?::(?<line>[0-9]+):(?<col>[0-9]+))?)(?<boundary_end>[^a-zA-Z0-9.])",
341343
"g"
342344
);
343-
html = html.replace(pathRegex, (match, boundary, inner, path, line, col) => {{
345+
html = html.replace(pathRegex, (match, boundary_start, inner, path, line, col, boundary_end) => {{
344346
const pos = (line !== undefined) ? `#L${{line}}` : "";
345-
return `${{boundary}}<a href="https://github.com/{owner}/{repo}/blob/{sha}/${{path}}${{pos}}" class="path-marker">${{inner}}</a>`;
347+
return `${{boundary_start}}<a href="https://github.com/{owner}/{repo}/blob/{sha}/${{path}}${{pos}}" class="path-marker">${{inner}}</a>${{boundary_end}}`;
346348
}});
347349
348350
// 6. Add the html to the DOM

0 commit comments

Comments
 (0)