Rules Hub
Coding Rules Library
← 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
When splitting a path and removing empty leading/trailing segments, split then filter out falsy entries rather than pre-trimming with a regex.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codejavascript
| 1 | url.replace(/(\/$)|(^\/)/g, '').split('/'); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejavascript
| 1 | url.split('/').filter(Boolean); |
Explanation (EN)
Objašnjenje (HR)