On Aug 29, 8:33 am, "Andrew Beers" <be... / tableausoftware.com> wrote: > I have looked through the archives for the mailing list, but didn't see > this issue addressed. So here goes. > > My local machine is named 3beers-wrk. I achieved this by putting an > entry in my local hosts file (since I'm on Windows, this would be in > \windows\system32\drivers\etc\hosts). However, I have also seen the > issue below reproduce with a machine whose name is similar, say > 12345-server. > > Below is a capture of my session with the shell, then with irb: > > H:\>ping 3beers-wrk > > Pinging 3beers-wrk [127.0.0.1] with 32 bytes of data: > > Reply from 127.0.0.1: bytes=32 time<1ms TTL=128 > > Reply from 127.0.0.1: bytes=32 time<1ms TTL=128 > > ... > > H:\>irb > > irb(main):001:0> require 'uri' > > => true > > irb(main):002:0> URI.parse("http://3beers-wrk.tsi.lan") > > => #<URI::HTTP:0x1612dc0 URL:http://3beers-wrk.tsi.lan> > > irb(main):003:0> URI.parse("http://3beers-wrk") > > URI::InvalidURIError: the scheme http does not accept registry part: > 3beers-wrk (or bad hostname?) > > from > c:/p4/workgroup-1.0/workgroup-support/ruby/lib/ruby/1.8/uri/generic.rb:1 > 94:in `initialize' > > from > c:/p4/workgroup-1.0/workgroup-support/ruby/lib/ruby/1.8/uri/http.rb:46:i > n `initialize' > > from > c:/p4/workgroup-1.0/workgroup-support/ruby/lib/ruby/1.8/uri/common.rb:48 > 4:in `new' > > from > c:/p4/workgroup-1.0/workgroup-support/ruby/lib/ruby/1.8/uri/common.rb:48 > 4:in `parse' > > from (irb):3 > > from > c:/p4/workgroup-1.0/workgroup-support/ruby/lib/ruby/1.8/uri/http.rb:57 > > URI.parse() is not properly parsing the non-qualified name 3beers-wrk > (though it does properly parse a fully-qualified hostname), which seems > to be in line with the grammar set forth in RFC2396. However, the RFC > makes the following comment: "In practice, however, the host component > may be a local domain literal" (section 3.2). This suggests that the > above URI is entirely valid. Further, this URI is acceptable to Web > browsers. > > Is this a bug? How can I handle this seemingly valid URI? It looks like URI.parse doesn't like the leading number: irb(main):001:0> require 'uri' irb(main):003:0> URI.parse("http://xshare") => #<URI::HTTP:0x16fd906 URL:http://xshare> irb(main):004:0> URI.parse("http://xshare-foo") => #<URI::HTTP:0x16fc498 URL:http://xshare-foo> irb(main):006:0> URI.parse("http://3qshare") URI::InvalidURIError: the scheme http does not accept registry part: 3qshare (or bad hostname?) from C:/ruby/lib/ruby/1.8/uri/generic.rb:195:in `initialize' from C:/ruby/lib/ruby/1.8/uri/http.rb:78:in `initialize' from C:/ruby/lib/ruby/1.8/uri/common.rb:488:in `new' from C:/ruby/lib/ruby/1.8/uri/common.rb:488:in `parse' from (irb):6 I couldn't tell you what the proper behavior is. Regards, Dan