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 ruleP1universalStack: node
urlencodingcohesion
Encode URL components at the point the URL is built
Apply encodeURIComponent where the URL string is assembled, not far away in the caller, so encoding stays coupled to URL construction.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | const q = encodeURIComponent(input); |
| 2 | // ...much later... |
| 3 | buildUrl(q); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | function buildUrl(input: string) { |
| 2 | return `${base}?q=${encodeURIComponent(input)}`; |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)