vendredi 20 avril 2018

How to compare Laravel's url()->previous() with url()->current()

It seems Laravel's url()->previous() and url()->current() is broken. I can't do a if previous == current, because previous outputs with http:/https: and ends with /, and current outputs without this.

I thought this was not going to be a problem. I could just prepend http:/https: to the url()->current() and move on with my life, but apparently it was not going to be that simple.

The problem: $url_1 != $url_2

Code:

$url_1 = url()->previous();
$url_2 = url()->current();

var_dump( $url_1 );
var_dump( $url_2 );

Output:

string(22) "http://localhost:3000/"
string(21) "//localhost:3000"

Attempt to fix:

Code:

$url_1 = url()->previous();
$url_2 = 'http:' . url()->current() . '/';

var_dump( $url_1 );
var_dump( $url_2 );

Output:

string(22) "http://localhost:3000/" 
string(27) "http://localhost:3000/" 

So $url_1 is still not equal to $url_2. Does anyone know what's going on here? Seems to me that http: is being treated as a single character.

How can I actually compare the two, because as it is now, $url_1 is never going to be equal to $url_2...



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2F2w92D
via IFTTT

Aucun commentaire:

Enregistrer un commentaire