24
Views
6
Comments
Solved
Adding HTTPS:// to url (www.test.com) but if it already has https:// do nothing

When a user is typing in a url in a text field within the OnPreviousNextClick in an assign i want to add "https://" to a url that does not contain it ( www.test.com) but if the url is (https://www.test.com) do nothing and leave it as is. 

If(Index(URL,"https://") <> -1,URL, "https://" + URL)  i have this just now which works for if URL doesn't contain but if i have (https://www.test.com) it makes it https://https://www.test.com

2025-12-22 13-50-43
Sherif El-Habibi
Champion
Solution

Hello Tahm Kench 😄,

I tried it on my side, and it’s working based on your condition. There’s one scenario I’m not 100% sure about: if you click the button more than once, https://www.test.com could become https://https://www.test.com. This isn’t caused by the condition itself, but by the click trigger firing multiple times.

So when it reaches the condition, it sees https://https://www.test.com. The index is not -1, so it evaluates as true but the extra https:// wasn’t added by the condition itself; it’s already there from multiple clicks.

Another scenario is that it’s very case-sensitive. For example, if you forget to include a trailing /, it may behave differently and be automatically added.

2016-04-22 00-29-45
Nuno Reis
 
MVP

Hello.

That expression should work.

If(Index(URL,"https://") = 0, URL, "https://" + URL)  is even better as it always looks at the very start.

Can you share the flow? The error is probably somewhere else.

2023-10-16 05-50-48
Shingo Lam

Firstly, your condition is correct, nothing to change. I wanna know whether the URL is the variable binding to the input or it is the other one. 

Its safe to let result = your if statement with the input variable, which means 2 variables. Then it won't double add the https:// to the same variable

@Nuno Reis is correct that index = 0 means "start with", it is best condition for your case 

2021-09-06 15-09-53
Dorine Boudry
 
MVP

@Shingo Lam 

I don't understand this. Why would assigning URL instead of some other variable cause the double

2023-10-16 05-50-48
Shingo Lam

Hi @Dorine Boudry ,

As I mentioned, its safe. My recommendation is to avoid the double assignment to the same variable, so use 1 separate variable for result can eliminate the programming mistake like that

2024-10-05 13-30-20
Huy Hoang The

Hi @Calum Rogers ,

I think you need to share that code flow because the conditional statement you're using is correct. However, you might have some incorrect assignments around it.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.