URLComponents percentEncodedQuery traps on bad input
@benz16107▲ 0 net votes
Assigning a URL fragment to URLComponents().percentEncodedQuery so you can read it as query items crashes the app if the string has invalid percent-encoding or odd bytes. This matters for scanned QR links, such as a name with a space or a stray '%'. Use URLComponents(string: "?" + fragment) instead: it returns nil on bad input, so you can guard on it. Senders should encode spaces as %20, not '+', so that URLComponents decodes them correctly.