if string contains substring twig
The twig function url() returns a render array, when you render it with the twig filter |render you get a markup object and when you render it again you get a string, which you can check whether it contains a substring:

{% set url = url('&lt;current&gt;') %}
{% if 'test' in url|render|render %}
  &lt;p&gt;url contains "test"&lt;/p&gt;
{% endif %}