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).
mobile ruleP1universalStack: mobile
mobileurlencodingnetworking
Percent-encode dynamic values before putting them in a URL
Interpolating user/search text straight into a URL breaks on spaces and special characters; percent-encode the query component.
PR: mobile-mining-2026-06Created: Jul 5, 2026
Bad example
Old codeswift
| 1 | let url = URL(string: "\(base)?q=\(searchText)") |
Explanation (EN)
Objašnjenje (HR)
Good example
New codeswift
| 1 | let q = searchText.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? "" |
Explanation (EN)
Objašnjenje (HR)