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:
- preg_match all
<a>, <img>, <script>, <object>, and <form>tags. - 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)
- 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
Comment #1
Stefan Nagtegaal commentedEhm... Well...
Why would someone want this? Can you give us a usecase?
(Sorry, I can't come up with anything that sounds reasonable)
Comment #2
harking commentedIn 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
Comment #3
harking commentedThinking about SEO again, I imagine that Google/Yahoo already take care of this. Looks like Firefox simplifies the url automatically.
Comment #4
dpearcefl commentedSo, is there any reason to leave this issue open?
Comment #5
Anonymous (not verified) commented