I am making a search engine from scratch (lol), and I am stick with this problem:
When a user submits a URL, my "spider" "crawls" it for other links.
Some people of course use <a href="/page">
instead of <a href="http://long-domain.com/page">
, so I detect that with
if(substr($link->getAttribute('href'), 0, 1) == '/')
And add a domain in front of it. BUT, whenever I do add a domain, some links become http://php.net//abcd
. As you can see its //
.
Now, my idea was to make my script edit the submitted URL so if it has a slash at the end, it'll be removed, but I have no idea how to remove it.