sindresorhus / linkify-urls

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

Escape the automatic URL value #17

Closed fregante closed 6 years ago

fregante commented 6 years ago

Fixes #14 Fixes sindresorhus/refined-github#811

It does not escape the value because the user might not want that and we don't want an option for that. So they should use escape-goat explicitly in that case.

sindresorhus commented 6 years ago

Why not use the new text option in create-html-element?

fregante commented 6 years ago

Because a I'm a dummy

fregante commented 6 years ago

However it doesn't look any better

Edit: or perhaps this? Still much longer

const linkify = (href, options) => {
    const opts = {
        name: 'a',
        attributes: Object.assign({href: ''}, options.attributes, {href})
    };
    if (typeof options.value === 'undefined') {
        opts.value = href;
    } else {
        opts.html = options.value;
    }
    createHtmlElement(opts);
};
sindresorhus commented 6 years ago

What if we change this module to have a text and html option too instead of value?

fregante commented 6 years ago

As part of #10 yes