Using the STRING_ESCAPE function found here I am escaping certain columns with string values so that they fit in a JSON format. However when it is applied to URLs it behaves, in my opinion, strangely.
SELECT STRING_ESCAPE('https://www.website.com/page', 'json')
returns https:\/\/www.website.com\/page
.
I can understand that indeed according to this post forward slashes are allowed, not required in JSON and therefore they are included when using this function. But if you create an HTML tag with this value (https:\/\/www.website.com\/page
) the link no longer works as, my browser at least, is trying to surf to https://www.website.com//page
.
Since I don't know if my original string contains \/
I can't just use REPLACE(STRING_ESCAPE([column], 'json'), '\/', '/')
to solve this.
Is there an option to disable the escaping of forward slashes? Or any other clever solution to this problem?