Support the ongoing development of Laravel.io →
Architecture
Last updated 7 months ago.
0

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

Hello from route 1 (/r1), 
resultFromroute = http://myapp-v2f.net/r1 = route('namedroute1')
resultFromLinkOnResultFromRoute = <a href="http://myapp-v2f.net/r1";>http://myapp-v2f.net/r1</a> = HTML::link(resultFromroute,resultFromroute)
Last updated 7 months ago.
0

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.

http://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_ho...

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 7 months ago.
0

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

Headers:
text/html, application/xhtml+xml, */*
da
Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko
gzip, deflate
myapp_v2f.net
1
Keep-Alive

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'));
}

output:

HTML::link('/r1')
    <a href="http://myapp_v2f.net/r1">http://myapp_v2f.net/r1</a>
route('namedroute'):
    http://myapp_v2f.net/r1
HTML::link(route('namedroute')):
    <a href="http://myapp_v2f.net/http://myapp_v2f.net/r1">http://myapp_v2f.net/http://myapp_v2f.net/r1</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 7 months ago.
0

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 7 months ago.
0

Sign in to participate in this thread!

Cloudways

Your banner here too?

Moderators

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

Your logo here?

Laravel.io

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

© 2022 Laravel.io - All rights reserved.