Q:

How do I prevent strings in custom link formulas from becoming URL encoded?

I'm trying to build a custom link formula that will return two different URLs depending on the value in a field. When I quote the URL string within the formula function, it becomes URL encoded when it is evaluated. When I come to click the link in the layout, I get the following error:
"You have sent us an Illegal URL or an improperly formatted request."
The custom link formula looks like this:
{!IF(
    ISBLANK( Account.AccountNumber ),
    "https://example-blank.com/page.html?id=blank",
    "https://example-value.com/page.html?id=value"
)}

I'd expect this to return the quoted URL strings as the link URL, however the string gets URL encoded somewhere along the way, and the link that this actually produces looks like https%3A%2F%2Fexample-blank.com%2Fpage.html%3Fid%3Dblank, and is why the illegal URL error is being thrown.
How do I include the full URL within the function without it becoming URL encoded?
Alternatively, how do I achieve my desired result of dynamically linking users to two different sites in a Lightning compatible way?

A:

Make use of URLFOR function in formula builder to do so:-  
{! URLFOR( "https://example-blank.com/page.html?", null, [id=Mission__c.Id] ) }

to build effective URL for your custom link. 
Read more here:- Constructing Effective Custom URL Buttons and Links

