From 6653d1c19651e51aadbc661c69c6b6a5c2e7c850 Mon Sep 17 00:00:00 2001 From: Joel Labes Date: Thu, 2 Dec 2021 14:00:43 +1300 Subject: [PATCH] Backport android url changes from #426 --- integration_tests/data/web/data_url_host.csv | 5 ++++- macros/web/get_url_host.sql | 11 ++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/integration_tests/data/web/data_url_host.csv b/integration_tests/data/web/data_url_host.csv index c32fbf8d..2350bb7a 100644 --- a/integration_tests/data/web/data_url_host.csv +++ b/integration_tests/data/web/data_url_host.csv @@ -1,4 +1,7 @@ original_url,parsed_url www.google.co.uk?utm_source=google&utm_medium=cpc&utm_campaign=spring-summer,www.google.co.uk http://witanddelight.com/2018/01/tips-tricks-how-run-half-marathon-first-time/,witanddelight.com -https://www.nytimes.com/2018/01/01/blog,www.nytimes.com \ No newline at end of file +https://www.nytimes.com/2018/01/01/blog,www.nytimes.com +android-app://m.facebook.com/,m.facebook.com +docs.nytimes.com/2021/01/01/index.js?utm_source=google,docs.nytimes.com +https://m.facebook.com/,m.facebook.com \ No newline at end of file diff --git a/macros/web/get_url_host.sql b/macros/web/get_url_host.sql index b1e8e4de..d6662576 100644 --- a/macros/web/get_url_host.sql +++ b/macros/web/get_url_host.sql @@ -4,23 +4,24 @@ {% macro default__get_url_host(field) -%} -{%- set parsed = +{%- set parsed = dbt_utils.split_part( dbt_utils.split_part( dbt_utils.replace( - dbt_utils.replace(field, "'http://'", "''" + dbt_utils.replace( + dbt_utils.replace(field, "'android-app://'", "''" + ), "'http://'", "''" ), "'https://'", "''" ), "'/'", 1 ), "'?'", 1 ) - + -%} - + {{ dbt_utils.safe_cast( parsed, dbt_utils.type_string() )}} - {%- endmacro %} \ No newline at end of file