Skip to content

Commit

Permalink
Add whitespace to fallback output so the URL is correctly linkified (#12
Browse files Browse the repository at this point in the history
)
  • Loading branch information
kyeotic authored and sindresorhus committed Sep 1, 2019
1 parent e4625fc commit d879caf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const supportsHyperlinks = require('supports-hyperlinks');

module.exports = (text, url, options = {}) => {
if (!supportsHyperlinks.stdout) {
return options.fallback ? options.fallback(text, url) : `${text} (${url})`;
return options.fallback ? options.fallback(text, url) : `${text} (\u200B${url}\u200B)`;
}

return ansiEscapes.link(text, url);
Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test('default fallback', t => {

const actual = m('My Website', 'https://sindresorhus.com');
console.log(actual);
t.is(actual, 'My Website (https://sindresorhus.com)');
t.is(actual, 'My Website (\u200Bhttps://sindresorhus.com\u200B)');
});

test('custom fallback', t => {
Expand Down

0 comments on commit d879caf

Please sign in to comment.