I changed all my URL field types (both in Collection schema and interface element (text) to type Text, because I wanted to get rid of the mandatory "http://" and "https://". Users simply wanted to type "www.mysite.com".
When I now build a .html <a href=-string for a text element using this string without http(s), I get an error:
Wix code SDK error: Failed to create link because Error: Unsupported link type
I fear that Wix finds the missing http(s) a problem and will not build a link. So I have to check it and add it myself. Is there a quick, perhaps standard function to do so?
Hi Giri,
Yeah, you're right. The redirect is done by the server. There are many things to worry about when setting up a server. Another example would be having the server treat www.domain.com and domain.com the same.
Yisrael
Yisrael, I did some reading and it turns out the redirect is not done by the browser, but by the server. But only is such a redirect is in place. So I will just add http and if there is no redirect on the server if it only supports https, then the user will just have to edit his URL. I´ll put this into a help text.
Not sure if the 443 behavior is standard, but it seems to me that I've also seen this. "Standard behavior"? Not sure, but I suspect it's at least "recommended behavior".
I was going to add "First check if the "https://" exists - but I knew you'd figure it out. ☺️
Just another thing: if I have to add something myself, I do not know if the URL is on 443. So I tried a https site with http and in browser it went automatically to https of the site. Is that standard behaviour across browsers or servers?
Thanks. But if someone already added the http(s) in the URL, you get it twice. I´ll just check myself and add if is not there. Just wanted to know if there is a more elaborate and failsafe standard check + add.
Nothing official: Just a quick concatenate should do it: "https://" + linkText;