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
urlquery-paramsapi
Append the query separator only when query params exist
Don't hard-code a trailing '?' on a URL; add it only when there are params so empty-param URLs stay clean.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codejavascript
| 1 | const url = `/api/threads?${new URLSearchParams(params)}`; // '/api/threads?' when empty |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejavascript
| 1 | const qs = new URLSearchParams(params).toString(); |
| 2 | const url = qs ? `/api/threads?${qs}` : '/api/threads'; |
Explanation (EN)
Objašnjenje (HR)