How to get uri from Url object in twig? I want to inject Font Awesome icons to user menu based on the route/link of each item.

But it looks like there is no way to get the path grom the url object. I tried everything I could think of but nothing worked. It's like the url object won't give any data in Twig.

This is what I am trying to do in menu template for user acocunt:

&lt;li{{ item.attributes.addClass(classes) }}&gt;
                    {% set uri = path(item.url.routeName) %}
                    &lt;pre&gt;{{ dump(item) }}&lt;/pre&gt;
                    &lt;pre&gt;{{ dump(uri) }}&lt;/pre&gt;
                    {% if uri == 'user' %}
                        &lt;i class="fa fa-user"&gt;&lt;/i&gt;
                    {% elseif uri == 'user/logout' %}
                        &lt;i class="fa fa-sign-out"&gt;&lt;/i&gt;
                    {% elseif uri == 'user/register' %}
                        &lt;i class="fa fa-user-plus"&gt;&lt;/i&gt;
                    {% elseif uri == 'user/login' %}
                        &lt;i class="fa fa-sign-in"&gt;&lt;/i&gt;
                    {% endif %}
                    {{ link(item.title, item.url) }}
                    {% if item.below %}
                        {{ menus.menu_links(item.below, attributes, menu_level + 1) }}
                    {% endif %}
                &lt;/li&gt;
{% set uri = item.url.toString %} will also work.