Between Pressflow 6.22.102 and 6.22.104, there was a small but substantial change. The url()
function no longer normalizes leading slashes.
This brought it back inline with Drupal 6.x behaviour, but has also led to a number of our sites showing links with two trailing slashes. Browsers interpret <a href=”//…”> as a reference to a domain, not a resource (so as if it were http://…) and this leads to broken URLs.
The problem arises when a Drupal path is passed through url()
(or calling functions like l()
) more than once. This can happen in your own code, or it can happen in Views: if you use Views fields, and render a path out, but then e.g. exclude it from display and use its token elsewhere.
If you’re building your own links with Views fields, don’t retrieve a node path field [path]
for use, as this immediately gets rendered with a leading slash and is then unuseable as a link token elsewhere: it will get a second leading slash. Instead, get the bare node ID [nid]
, and build links of the form node/[nid]
. When these get passed through url()
one time only, they get turned into the friendly [path]
aliases anyway.