Support the ongoing development of →
Last updated 2 years ago.

Changing the underscore '_' to a hyphen '-' also seems to work.

Hello from route 1 (/r1), 
resultFromroute = = route('namedroute1')
resultFromLinkOnResultFromRoute = <a href=""></a> = HTML::link(resultFromroute,resultFromroute)
Last updated 2 years ago.

I guess that technically it might be a regex issue, but considering that an underscore is not a valid character in a hostname, I wouldn't expect to get much traction.

In fact, the invalid hostname might even be sent from your browser - this might not be a Laravel issue at all. Check your HTTP headers and see if there is something weird going on there.

Last updated 2 years ago.

Hi lookitsatravis

thanks for the response, and interesting with the valid hostname.

I have just changed the hostname to something valid and thats all good...

anyway: I don't think that the headers are weird, mostly because, I wouldn't expect apache to serve the correct page if that was the case...

this is the response from php's getallheaders

text/html, application/xhtml+xml, */*
Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko
gzip, deflate

I have printed the output using a small unittest , that I guess 'might' not be infuenced by headers et al.

public function testHTMLLinkWhitUnderscoreInAppUrl()
  echo "\r\n" . 'HTML::link(\'/r1\')'."\r\n\t".HTML::link('/r1');
  echo "\r\n" . 'route(\'namedroute\'):'."\r\n\t".route('namedroute');
  echo "\r\n" . 'HTML::link(route(\'namedroute\')):'."\r\n\t". HTML::link(route('namedroute'));


    <a href=""></a>
    <a href=""></a>

I am thinking, that perhaps the HTML::link could issue a warning if the app name isn't valid and debug==true

Last updated 2 years ago.

The problem is exactly because of the underscore in your host name. Take a look at the Illuminate UrlGenerator class. It has a method called isValidUrl which validates the $path variable through:

filter_var($path, FILTER_VALIDATE_URL);

Since the underscore isn't valid, it fails. But I think a warning here doesn't make sense, since this actually has nothing to do with Laravel.

Last updated 2 years ago.

Sign in to participate in this thread!


Your banner here too?


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.