Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
On the frontpage, `drupalSettings.path.currentPath` returns "node". It should return "" (nothing) to keep URLs consistent.
Comment | File | Size | Author |
---|
Comments
Comment #2
mondrakeRelated, #2687453: drupalSettings.path.currentPath refers to the route's URL even when page is accessed through an URL alias
Comment #3
Wim LeersComment #5
aerozeppelin CreditAttribution: aerozeppelin commentedInitial patch.
Comment #7
cilefen CreditAttribution: cilefen commentedComment #8
cilefen CreditAttribution: cilefen commentedComment #9
dawehnerNote: We could store the path.matcher in a variable
Comment #10
aerozeppelin CreditAttribution: aerozeppelin commentedChanges as per #9.
Comment #11
dawehnerThis looks great for me
Comment #14
sudhanshug CreditAttribution: sudhanshug commentedThe patch no longer could be applied to 8.4.x
I re-rolled the patch to apply cleanly to the latest version.
Comment #15
sudhanshug CreditAttribution: sudhanshug commentedComment #17
sudhanshug CreditAttribution: sudhanshug commentedIn #14, it shows that the patch passes the tests. But in #16, I don't how it is saying that the patch failed testing.
It may be jenkins bug.
Changing the status back to 'needs review'
Comment #21
raphaeltbm CreditAttribution: raphaeltbm commentedI don't agree at all with the proposed solution here.
Plus there is a high risk of side-effects with the current solution (search for "curentPath" to see the current usage in core and contribs).
currentPath
is designated to give the current internal path, there is nothing wrong with the returned value on a frontpage context or whatever the context.If you need a friendly URL of the current page for tracking or SEO or other purpose, you should add a new key in
$path_settings
and do something like:Or do that in a
my_module_page_attachments_alter()
via $attachments['#attached']['drupalSettings']['my-module']
.And you can always use
drupalSettings.path.isFront
for specific scenarios on the frontpage.I hide the current patches proposed as they could mislead some people. Feel free to open the issue again if you really want to add a new key in
drupalSettings.path
for the core or if you think that i'm wrong.Comment #22
droplet CreditAttribution: droplet commentedHmm, you're right...
We have to add something like `slug` then and rename currentUrl to
internalPath
(matching D8's PHP code$url->getInternalPath()
)Comment #23
droplet CreditAttribution: droplet commenteddon't meant to change it