Gekd
Gekd

Reputation: 3

How to fix a URL colon error that changes colon to %3a

I have a URL as below

components.host = "37.143.66.25:9875"

This URL contains a colon :, but when I try to make a request I get this error message

NSLocalizedDescription=A server with the specified hostname could not be found., NSErrorFailingURLStringKey=http://37.143.66.25%3a9875/spots/test, NSErrorFailingURLKey=http://37.143.66.25%3a9875/spots/test, _kCFStreamErrorDomainKey=12}

And in this error message, colon : is displayed as %3a.

What can I do?

Upvotes: 0

Views: 237

Answers (1)

Asperi
Asperi

Reputation: 257563

Add host and port separately, like (assuming components is URLComponents)

components.host = "37.143.66.25"
components.port = 9875

otherwise it thinks that your port is part of host name

Upvotes: 2

Related Questions