terminal-link
Advanced tools
Comparing version 2.0.0 to 2.1.0
declare namespace terminalLink { | ||
interface Options { | ||
/** | ||
Override the default fallback. | ||
Override the default fallback. If false, the fallback will be disabled. | ||
@default `${text} (${url})` | ||
*/ | ||
fallback?: (text: string, url: string) => string; | ||
fallback?: ((text: string, url: string) => string) | false; | ||
} | ||
@@ -17,3 +17,4 @@ } | ||
[Supported terminals.](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda) | ||
For unsupported terminals, the link will be printed in parens after the text: `My website (https://sindresorhus.com)`. | ||
For unsupported terminals, the link will be printed in parens after the text: `My website (https://sindresorhus.com)`, | ||
unless the fallback is disabled by setting the `fallback` option to `false`. | ||
@@ -20,0 +21,0 @@ @param text - Text to linkify. |
@@ -7,2 +7,7 @@ 'use strict'; | ||
if (!supportsHyperlinks[target]) { | ||
// If the fallback has been explicitly disabled, don't modify the text itself. | ||
if (options.fallback === false) { | ||
return text; | ||
} | ||
return options.fallback ? options.fallback(text, url) : `${text} (\u200B${url}\u200B)`; | ||
@@ -9,0 +14,0 @@ } |
{ | ||
"name": "terminal-link", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Create clickable links in the terminal", | ||
"license": "MIT", | ||
"repository": "sindresorhus/terminal-link", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
@@ -40,5 +41,5 @@ "name": "Sindre Sorhus", | ||
"clear-module": "^4.0.0", | ||
"tsd": "^0.7.4", | ||
"xo": "^0.24.0" | ||
"tsd": "^0.11.0", | ||
"xo": "^0.25.3" | ||
} | ||
} |
@@ -7,3 +7,2 @@ # terminal-link [![Build Status](https://travis-ci.org/sindresorhus/terminal-link.svg?branch=master)](https://travis-ci.org/sindresorhus/terminal-link) | ||
## Install | ||
@@ -15,3 +14,2 @@ | ||
## Usage | ||
@@ -26,3 +24,2 @@ | ||
## API | ||
@@ -56,6 +53,8 @@ | ||
Type: `Function` | ||
Type: `Function | false` | ||
Override the default fallback. The function receives the `text` and `url` as parameters and is expected to return a string. | ||
If set to `false`, the fallback will be disabled when a terminal is unsupported. | ||
### terminalLink.isSupported | ||
@@ -83,3 +82,2 @@ | ||
## Related | ||
@@ -86,0 +84,0 @@ |
6494
70
83