Skip to content

Commit d879caf

Browse files
kyeoticsindresorhus
authored andcommitted
Add whitespace to fallback output so the URL is correctly linkified (#12)
1 parent e4625fc commit d879caf

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const supportsHyperlinks = require('supports-hyperlinks');
44

55
module.exports = (text, url, options = {}) => {
66
if (!supportsHyperlinks.stdout) {
7-
return options.fallback ? options.fallback(text, url) : `${text} (${url})`;
7+
return options.fallback ? options.fallback(text, url) : `${text} (\u200B${url}\u200B)`;
88
}
99

1010
return ansiEscapes.link(text, url);

test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ test('default fallback', t => {
2424

2525
const actual = m('My Website', 'https://sindresorhus.com');
2626
console.log(actual);
27-
t.is(actual, 'My Website (https://sindresorhus.com)');
27+
t.is(actual, 'My Website (\u200Bhttps://sindresorhus.com\u200B)');
2828
});
2929

3030
test('custom fallback', t => {

0 commit comments

Comments
 (0)