get_url_parameter does not work for small parameters that are included in other params
Stephen986 opened this issue · 2 comments
Describe the bug
The get_url_parameter generally works for long parameters, but if it's a small param that could be included in other parameters, it will not work properly. While UTMs are the most common types of URL parameters, I've worked with companies that those &c
, &e
, and other tiny parameters in them that doesn't work with this macro.
Steps to reproduce
Use get_url_parameter
on a URL where the characters of one parameter is also inside another parameter, such as:
select {{ dbt_utils.get_url_parameter(field='page_url', url_parameter='ce') }}
where page_url = 'https://www.dbt.com?utm_source=github'
Expected results
In the above example, I would expect the macro to not return a parameter, because it doesn't have &ce
or ?ce
in it.
Actual results
The macro would return github as the 'ce' parameter.
Screenshots and log output
System information
The contents of your packages.yml
file:
Which database are you using dbt with?
- postgres
- redshift
- bigquery
- snowflake
- other (specify: ____________)
The output of dbt --version
:
<output goes here>
Additional context
Are you interested in contributing the fix?
The solution I ended up using was to coalesce a split part of ?param=
and a split part of ¶m=
together. That way it works for either of those situations, but it's not triggered by the param being at the end of another param.
I can submit a PR for that if everyone likes that solution? It's ugly, but it works for all the use cases I deal with.
Thanks for raising this issue @Stephen986!
If you raise a PR with the solution you used, I can take a look at it.