From d879caf7904353f35fa5a6962f71939c10ccd0ca Mon Sep 17 00:00:00 2001 From: Tim Kye Date: Sat, 31 Aug 2019 21:53:02 -0700 Subject: [PATCH] Add whitespace to fallback output so the URL is correctly linkified (#12) --- index.js | 2 +- test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 5e41eaf..62a4b69 100644 --- a/index.js +++ b/index.js @@ -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); diff --git a/test.js b/test.js index 6dc404b..702dc83 100644 --- a/test.js +++ b/test.js @@ -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 => {