Reputation: 277
How can I turn domain.com into https://www.domain.com (the actual address)? Is there an easy API for this?
The purpose is to allow a user to enter a domain in preferences and allow my app to convert that into a fully qualified web URL like a web browser does when I type google.com it returns http://www.google.com (ish).
Upvotes: 0
Views: 194
Reputation: 43743
If typing your domain.com results in https://www.your domain.com then the server is redirecting. Here is a rule to follow:
https://
domain the user typed". Connect to that, and follow any 301 (permanent) redirects until you get a 200 response. Save the URL you end up at as the permanent one.http://
instead of https://
.Do not assume that the "proper" URL contains "www.
"; if it should, then the server will redirect.
Upvotes: 2
Reputation: 75981
Use the NSURL
class. More specifically, use initWithScheme:host:path
where scheme is "http", host is your string and path is empty.
Upvotes: 0
Reputation: 391818
What's so hard about putting "http://www." in front?
How does that require an API?
Are you asking about the string concatenation API?
Upvotes: 0