-
-
Save waako/537e85361dba73bd5212716ad2aab540 to your computer and use it in GitHub Desktop.
get the domain from a url (twig)
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
{% set no_protocol = url|split('//')[1] ?: url %} | |
{% set only_domains = no_protocol|split('/')[0] ?: no_protocol %} | |
{% set url_domain = '' %} | |
{% if only_domains|split('.')[2] %} | |
{% set url_domain = only_domains|split('.')[1] %} | |
{% else %} | |
{% set url_domain = only_domains|split('.')[0] %} | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment