New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

won't parse domains #115

Closed
chovy opened this Issue Sep 7, 2013 · 6 comments

Comments

Projects
None yet
2 participants
@chovy

chovy commented Sep 7, 2013

search (google.com)

this string fails.

@rodneyrehm

This comment has been minimized.

Show comment
Hide comment
@rodneyrehm

rodneyrehm Sep 7, 2013

Member

I'm sorry, but I don't understand the issue. are you calling .search("google.com")? Have you looked at what .search() does?

URI('/').search('google.com').toString() === "/?google.com";
Member

rodneyrehm commented Sep 7, 2013

I'm sorry, but I don't understand the issue. are you calling .search("google.com")? Have you looked at what .search() does?

URI('/').search('google.com').toString() === "/?google.com";
@chovy

This comment has been minimized.

Show comment
Hide comment
@chovy

chovy Sep 7, 2013

No the literal string 'google.com'. Is not parsed. Ignore the search that was just the context of my string.

-- Anthony

On Sep 7, 2013, at 1:32 AM, Rodney Rehm notifications@github.com wrote:

I'm sorry, but I don't understand the issue. are you calling .search("google.com")? Have you looked at what .search() does?

URI('/').search('google.com').toString() === "/?google.com";

Reply to this email directly or view it on GitHub.

chovy commented Sep 7, 2013

No the literal string 'google.com'. Is not parsed. Ignore the search that was just the context of my string.

-- Anthony

On Sep 7, 2013, at 1:32 AM, Rodney Rehm notifications@github.com wrote:

I'm sorry, but I don't understand the issue. are you calling .search("google.com")? Have you looked at what .search() does?

URI('/').search('google.com').toString() === "/?google.com";

Reply to this email directly or view it on GitHub.

@rodneyrehm

This comment has been minimized.

Show comment
Hide comment
@rodneyrehm

rodneyrehm Sep 8, 2013

Member

I can see your problem now. In order to have an authority parsed as such, you need to add the protocol separator // otherwise the string is treated as a relative path.

URI('google.com').path() === 'google.com';
URI('//google.com').domain() === 'google.com';

This is not a bug. This is ambiguity at its best… :(

Member

rodneyrehm commented Sep 8, 2013

I can see your problem now. In order to have an authority parsed as such, you need to add the protocol separator // otherwise the string is treated as a relative path.

URI('google.com').path() === 'google.com';
URI('//google.com').domain() === 'google.com';

This is not a bug. This is ambiguity at its best… :(

@rodneyrehm rodneyrehm closed this Sep 8, 2013

@chovy

This comment has been minimized.

Show comment
Hide comment
@chovy

chovy Sep 8, 2013

I was actually trying this code with 'google.com' and it failed to recognize a url.

var source = "Hello www.example.com,\n"
    + "google.com is a search engine, like http://www.bing.com\n"
    + "http://exämple.org/foo.html?baz=la#bumm is an IDN URL,\n"
    + "http://123.123.123.123/foo.html is IPv4 and "
    + "http://fe80:0000:0000:0000:0204:61ff:fe9d:f156/foobar.html is IPv6.\n"
    + "links can also be in parens (http://example.org) "
    + "or quotes »http://example.org«.";

var result = URI.withinString(source, function(url) {
    return "<a>" + url + "</a>";
});

/* result is:
Hello <a>www.example.com</a>,
<a>http://google.com</a> is a search engine, like <a>http://www.bing.com</a>
<a>http://exämple.org/foo.html?baz=la#bumm</a> is an IDN URL,
<a>http://123.123.123.123/foo.html</a> is IPv4 and <a>http://fe80:0000:0000:0000:0204:61ff:fe9d:f156/foobar.html</a> is IPv6.
links can also be in parens (<a>http://example.org</a>) or quotes »<a>http://example.org</a>«.
*/

chovy commented Sep 8, 2013

I was actually trying this code with 'google.com' and it failed to recognize a url.

var source = "Hello www.example.com,\n"
    + "google.com is a search engine, like http://www.bing.com\n"
    + "http://exämple.org/foo.html?baz=la#bumm is an IDN URL,\n"
    + "http://123.123.123.123/foo.html is IPv4 and "
    + "http://fe80:0000:0000:0000:0204:61ff:fe9d:f156/foobar.html is IPv6.\n"
    + "links can also be in parens (http://example.org) "
    + "or quotes »http://example.org«.";

var result = URI.withinString(source, function(url) {
    return "<a>" + url + "</a>";
});

/* result is:
Hello <a>www.example.com</a>,
<a>http://google.com</a> is a search engine, like <a>http://www.bing.com</a>
<a>http://exämple.org/foo.html?baz=la#bumm</a> is an IDN URL,
<a>http://123.123.123.123/foo.html</a> is IPv4 and <a>http://fe80:0000:0000:0000:0204:61ff:fe9d:f156/foobar.html</a> is IPv6.
links can also be in parens (<a>http://example.org</a>) or quotes »<a>http://example.org</a>«.
*/

@rodneyrehm rodneyrehm reopened this Sep 8, 2013

@rodneyrehm

This comment has been minimized.

Show comment
Hide comment
@rodneyrehm

rodneyrehm Sep 8, 2013

Member

Ok, so you're talking about URI.withinString. Please add this (vital) piece of information in the issue description the next time you open an issue somewhere…

The regular expression used to extract URIs from text expects a URI to either begin with a protocol (e.g. http://) or with the subdomain www. Feel free to modify the expression, located at URI.find_uri_expression, to your liking. for reference, URI.js is using the "gruber revised" from here.

Member

rodneyrehm commented Sep 8, 2013

Ok, so you're talking about URI.withinString. Please add this (vital) piece of information in the issue description the next time you open an issue somewhere…

The regular expression used to extract URIs from text expects a URI to either begin with a protocol (e.g. http://) or with the subdomain www. Feel free to modify the expression, located at URI.find_uri_expression, to your liking. for reference, URI.js is using the "gruber revised" from here.

@rodneyrehm

This comment has been minimized.

Show comment
Hide comment
@rodneyrehm

rodneyrehm Jan 23, 2014

Member

The issue is resolved in v1.12.0 see the docs for an enhanced API.

Member

rodneyrehm commented Jan 23, 2014

The issue is resolved in v1.12.0 see the docs for an enhanced API.

@rodneyrehm rodneyrehm closed this Jan 23, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment