if string contains substring twig I feel a bit dummy as I can't make it work..

I'm trying to check if a string contains substring in my twig.

{% set url = url('&lt;current&gt;') %}
{{ url }}

{% if 'my-delivery' in url %}
    //print something
{% endif %}


The url is printed outside the if statement but it doesn't enter the if statement and the url contains 'my-delivery'.

Any idea why it doesn't work?
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 %}