sindresorhus / linkify-urls

Linkify URLs in a string
MIT License
160 stars 22 forks source link

Add support for custom HTML value #11

Closed yeskunall closed 6 years ago

yeskunall commented 6 years ago

Fixes #10

fregante commented 6 years ago

This fails with value: <falsy value like 0 or ''>

I'd suggest either Object.assign or a test against undefined instead of ||

yeskunall commented 6 years ago

You are correct. It picks up href if the other value in the expression is falsy. Sorry, I'll look into it. 🙈

fregante commented 6 years ago

So close to a merge! :)

yeskunall commented 6 years ago

@bfred-it honestly was expecting it to be an easy fix, but I seem to be stumped. I could use some help here.

I started by simply wrapping options.value in a String so as to explicitly convert the value, since the end result is a string anyway, but that didn't work out.

I'd suggest either Object.assign or a test against undefined instead of ||

Maybe you could elaborate a bit more on this?

fregante commented 6 years ago

typeof options.value === ‘undefined’ ? href : options.value

fregante commented 6 years ago

Thanks for the PR @yeskunall 🎉