{"action":"created","issue":{"url":"https://api.github.com/repos/IBM-Swift/Aphid/issues/12","repository_url":"https://api.github.com/repos/IBM-Swift/Aphid","labels_url":"https://api.github.com/repos/IBM-Swift/Aphid/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/IBM-Swift/Aphid/issues/12/comments","events_url":"https://api.github.com/repos/IBM-Swift/Aphid/issues/12/events","html_url":"https://github.com/IBM-Swift/Aphid/pull/12","id":171960865,"number":12,"title":"Fix for empty strings (e.g. in password)","user":{"login":"jmarcelino","id":3199956,"avatar_url":"https://avatars.githubusercontent.com/u/3199956?v=3","gravatar_id":"","url":"https://api.github.com/users/jmarcelino","html_url":"https://github.com/jmarcelino","followers_url":"https://api.github.com/users/jmarcelino/followers","following_url":"https://api.github.com/users/jmarcelino/following{/other_user}","gists_url":"https://api.github.com/users/jmarcelino/gists{/gist_id}","starred_url":"https://api.github.com/users/jmarcelino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmarcelino/subscriptions","organizations_url":"https://api.github.com/users/jmarcelino/orgs","repos_url":"https://api.github.com/users/jmarcelino/repos","events_url":"https://api.github.com/users/jmarcelino/events{/privacy}","received_events_url":"https://api.github.com/users/jmarcelino/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-18T17:50:56Z","updated_at":"2016-08-18T19:00:32Z","closed_at":"2016-08-18T19:00:16Z","pull_request":{"url":"https://api.github.com/repos/IBM-Swift/Aphid/pulls/12","html_url":"https://github.com/IBM-Swift/Aphid/pull/12","diff_url":"https://github.com/IBM-Swift/Aphid/pull/12.diff","patch_url":"https://github.com/IBM-Swift/Aphid/pull/12.patch"},"body":"Some brokers such as AT&T A2X expect an empty password so I instinctively tried to init Aphid with an empty string literal like this:\r\n`let client = Aphid(clientId: clientId, username: \"fa393bb9fa3b8b04aff1ff78433b8xxx\", password: \"\")`\r\nand found that crashes with _fatal error: unexpectedly found nil while unwrapping an Optional value_\r\n\r\nSetting password = nil (or omiting it) works but I'd argue it's less intuitive..\r\n\r\nI traced the problem down to calling String.data(using:...) on an empty String which returns nil - Extensions.swift line 38. \r\n\r\nI've added a conditional _if let_ to prevent this and in my testing it seems to have worked. \r\n\r\nI noticed the existing code structure lends very well to so wonder if it was there before but removed for some reason. If you feel this is the wrong way to fix it please feel free to ignore my PR :-)\r\n\r\n(I have signed the CLA already)"},"comment":{"url":"https://api.github.com/repos/IBM-Swift/Aphid/issues/comments/240822842","html_url":"https://github.com/IBM-Swift/Aphid/pull/12#issuecomment-240822842","issue_url":"https://api.github.com/repos/IBM-Swift/Aphid/issues/12","id":240822842,"user":{"login":"sandmman","id":8973287,"avatar_url":"https://avatars.githubusercontent.com/u/8973287?v=3","gravatar_id":"","url":"https://api.github.com/users/sandmman","html_url":"https://github.com/sandmman","followers_url":"https://api.github.com/users/sandmman/followers","following_url":"https://api.github.com/users/sandmman/following{/other_user}","gists_url":"https://api.github.com/users/sandmman/gists{/gist_id}","starred_url":"https://api.github.com/users/sandmman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sandmman/subscriptions","organizations_url":"https://api.github.com/users/sandmman/orgs","repos_url":"https://api.github.com/users/sandmman/repos","events_url":"https://api.github.com/users/sandmman/events{/privacy}","received_events_url":"https://api.github.com/users/sandmman/received_events","type":"User","site_admin":false},"created_at":"2016-08-18T19:00:32Z","updated_at":"2016-08-18T19:00:32Z","body":"This was more of an oversight than anything. I think using the empty string is more intuitive, so we'll go ahead with this. Thanks!"}}
{"actor":{"display_login":"sandmman"}}