Created
May 15, 2018 13:13
-
-
Save mattm/8a8a09745bdd68f7353ac78172e45580 to your computer and use it in GitHub Desktop.
Standardize URL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
current_url, | |
CASE | |
WHEN STRPOS(current_url, "?") > 0 THEN SUBSTR(current_url, 0, STRPOS(current_url, "?") - 1) | |
WHEN STRPOS(current_url, "#") > 0 THEN SUBSTR(current_url, 0, STRPOS(current_url, "#") - 1) | |
ELSE current_url | |
END AS url | |
FROM ( | |
SELECT 'https://www.helpscout.net/blog/beacon-preview-ui/' AS current_url | |
UNION ALL SELECT 'https://www.helpscout.net/blog/beacon-preview-ui/?utm_content=1234&utm_medium=social&utm_source=twitter' AS current_url | |
UNION ALL SELECT 'https://www.helpscout.net/blog/beacon-preview-ui/#example' AS current_url | |
); | |
+---------------------------------------------------------------------------------------------------------+---------------------------------------------------+ | |
| current_url | url | | |
+---------------------------------------------------------------------------------------------------------+---------------------------------------------------+ | |
| https://www.helpscout.net/blog/beacon-preview-ui/ | https://www.helpscout.net/blog/beacon-preview-ui/ | | |
| https://www.helpscout.net/blog/beacon-preview-ui/?utm_content=1234&utm_medium=social&utm_source=twitter | https://www.helpscout.net/blog/beacon-preview-ui/ | | |
| https://www.helpscout.net/blog/beacon-preview-ui/#example | https://www.helpscout.net/blog/beacon-preview-ui/ | | |
+---------------------------------------------------------------------------------------------------------+---------------------------------------------------+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment