mirror of
https://github.com/mandiant/capa.git
synced 2026-03-12 21:23:12 -07:00
webui: fix 404 for "View rule in capa-rules" by using proper URL encoding (#2868)
* webui: fix 404 for \"View rule in capa-rules\" links The createCapaRulesUrl function was constructing URLs by lowercasing the rule name and replacing spaces with hyphens, which produced URLs like /rules/packaged-as-single-file-.net-application/ (404). The capa-rules website uses the original rule name with URL encoding (e.g. /rules/packaged%20as%20single-file%20.NET%20application/). Use encodeURIComponent() on the rule name to produce correct URLs. Fixes #2482 * refactor: extract baseUrl constant in createCapaRulesUrl per code review
This commit is contained in:
committed by
GitHub
parent
4697902310
commit
e41b5fb150
@@ -77,8 +77,8 @@ export function createATTACKHref(attack) {
|
||||
*/
|
||||
export function createCapaRulesUrl(node) {
|
||||
if (!node || !node.data) return null;
|
||||
const ruleName = node.data.name.toLowerCase().replace(/\s+/g, "-");
|
||||
return `https://mandiant.github.io/capa/rules/${ruleName}/`;
|
||||
const baseUrl = "https://mandiant.github.io/capa/rules/";
|
||||
return `${baseUrl}${encodeURIComponent(node.data.name)}/`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user