Sometimes, when you use some text (usually the title) to create the path, and the cropped text ends in space, Pathauto transforms that space to the separator, usually a dash "-".

The problem is that many systems and programs don't recognize that "-" at the end of URL and strips it when transforming it in a clickable link, generating an error when any person click on it.

From my experience, the biggest problem in this moment for this issue is with Facebook. When a person share the content by a embedded share button is ok, but if the person copy&paste the URL and share as a status, the FB system does the dash stripping.

Another one that I've found is with Mozilla Thunderbird, when the e-mail comes as simple text and the system turns the URL in the text as clickable.

There must have more cases, so I'm suggesting it as a feature.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gionnibgud’s picture

Yep, I confirm the issue and I agree that it would be a good thing to strip the separator from the end but also from the beginning of the path.
And yes, it is a big issue particularly because of facebook ;)
It also happens at the beginning of the path like path: -something-else.
I'm not sure if it does cause any problem but sure it's ugly.

emclaughlin’s picture

Is this only a problem when there is whitespace at the beginning/end of a URL? Because it seems like it would be a simple enough fix to just make sure to use trim() before generating the alias.

emclaughlin’s picture

Assigned: Unassigned » emclaughlin
Status: Active » Needs review
FileSize
773 bytes

It turned out to be an order of operations issue. The truncating super long URLs was sometimes ending on a "-" instead of on the letter before it. So all that needed to happen was the final clean_separators needed to be after the alias was truncated, not before.

Status: Needs review » Needs work

The last submitted patch, pathauto-strip_trailing_separators-1549190-3.patch, failed testing.

emclaughlin’s picture

Status: Needs work » Needs review
FileSize
802 bytes

Okay, trying this again, with less fail this time, I hope.