I receive URLs from a PHP form with the _POST
method.
I am sure they are URLs because jquery validate plugin tests them before sending.
Then I process them in PHP.
However, I want to make sure that :
domain.com
or
domain.com/
end with a /
.
But, I want to make sure that :
domain.com/page
or
domain.com/page/
or
domain.com/dir/page/
or
domain.com/page.html
end without a /
.
I found : PHP: how to add trailing slash to absolute URL which was quite helpful.
I now use :
$rawarrival = $_POST["arrival"];
$url = parse_url($rawarrival);
if(!isset($url['path'])) $url['path'] = '/';
$arrival = $url['scheme']."://".$url['host'].$url['path'];
Nevertheless, I still can't make it to get a long URL (longer than just the domain) without a "/".
How should I twist that to make it work ?
Thank you.