vmg / rinku

Autolinking. Ruby. Yes, that's pretty much it.
ISC License
597 stars 67 forks source link

Autolinking fails with Rails localhost links #93

Open mokolabs opened 3 years ago

mokolabs commented 3 years ago

Rinku does not autolink localhost links used by Rails in :development mode.

irb(main):010:0> Rinku.auto_link("http://localhost:3000/products")
=> "http://localhost:3000/products"

While this URL might be missing a TLD, it's still weird that Rinku skips it. I actually thought Rinku was broken, but it turns out it was just ignoring my localhost links.

As a result, I believe my autolinking code will work in production -- where the URLs generated by the router will inherit the top-level domain from the production site -- but continue to fail in development and testing.

Ideally, for the sake of consistency, it should work in all three environments.

jrochkind commented 2 years ago

just ran into this too. Any interest in a fix from maintainers? I could try submitting a PR if so.

jrochkind commented 2 years ago

Oops, looks like this is a dup of #7 , which proposes a configuration fix, if a bit hacky.

Rinku.auto_link(text, nil, nil, nil, Rinku::AUTOLINK_SHORT_DOMAINS)

Does seem to work, although annoying to have to put in all those nils I didn't otherwise need.