There is no easy way to update Url option at render, so I can be usefull to use drupal_url for that.

You could for exemple render an url as absolute :

drupal_url(product_url, {absolute: true})

Comments

lalop created an issue. See original summary.

chi’s picture

Status: Active » Postponed (maintainer needs more info)

It's not clear what you mean. drupal_url() does accept Url options.

lalop’s picture

I mean drupal_url could accept an Url as first param

chi’s picture

Status: Postponed (maintainer needs more info) » Active

It's clear now though the case looks too specific.

chi’s picture

I think modifying existing URLs is out of scope of drupal_url function. The URL with proper options can be generated manually with core url function. Once #2907810: [PP-1] Add $entity->toUrl() and $entity->toLink() methods to allowed methods list in Twig sandbox policy lands it will much easier to obtain entity URLs in Twig.
Thanks.