Rules Hub
Code Ruleset
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP2universalStack: javascript
readabilitystringsarrayssplit
Drop empty segments with filter(Boolean) instead of regex trimming
Filter empty split segments only when interior empty segments are also insignificant.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codejavascript
| 1 | url.replace(/(\/$)|(^\/)/g, '').split('/'); |
Explanation (EN)
A complex end-trimming expression can be unnecessary for a normalized segment-list contract.
Objašnjenje (HR)
Good example
New codejavascript
| 1 | url.split('/').filter(Boolean); |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
Use split and empty-segment filtering only when the path contract treats every empty segment as insignificant.
Exceptions / Tradeoffs (EN)
Filtering removes interior empty segments too, unlike trimming only ends. Full URLs, repeated slash semantics and leading/trailing meaning require a URL/path-specific parser.