Convert urls such as:
<a href="/testo/drupal/./cows/../moo/./foo/../../bar/../"></a>
to something simple like:
<a href="/testo/drupal/"></a>

This could be performed once on node insertion to elements such as <a>, <img>, <script>, <object>, and <form>

Pseudo Code:

  1. preg_match all <a>, <img>, <script>, <object>, and <form> tags.
  2. Take that list of matches, save the original matching url so it can be looked up again. Then normalize the url. (Use something like PathParser)
  3. preg_replace all of the matches with the new url.

Would want to look out for poorly formatted tags. (No close bracket, funky characters, etc.)

Comments?

Comments

Stefan Nagtegaal’s picture

Ehm... Well...
Why would someone want this? Can you give us a usecase?
(Sorry, I can't come up with anything that sounds reasonable)

harking’s picture

In general it would help with SEO:
Instead of Google/Yahoo thinking that http://www.foo.com/moo/../ was its own page, and http://www.foo.com being another page, the URLs would be simplified to point to the same location.

Specifically for me:
I'm working on parsing out URLs for pathfilter module and replacing any local url such as /testo/moo/sites/default/files/picture.jpg with internal:sites/default/files/picture.jpg. This becomes difficult when the url is /testo/moo/../moo/./sites/default/files/picture.jpg

harking’s picture

Thinking about SEO again, I imagine that Google/Yahoo already take care of this. Looks like Firefox simplifies the url automatically.

dpearcefl’s picture

So, is there any reason to leave this issue open?

Anonymous’s picture

Status: Active » Closed (won't fix)