gajus / gajus/table

Terminal links are broken

Open
#113 1 comment 8 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
973
Forks
81
PR merge metrics
No merged PRs in 30d

Description

I'm testing this with [the exact test case from this repo](https://github.com/tahmidsadik112/table/blob/1226e8dab6e5fdc9b318c50307867c9d402cedb6/test/validateTableData.js#L62-L81):

```js
const { table } = require('table')

const OSC = '\u001B]';
const BEL = '\u0007';
const SEP = ';';
const url = 'https://example.com';
const text = 'This is a link to example.com';

const link = [
OSC,
'8',
SEP,
SEP,
url,
BEL,
text,
OSC,
'8',
SEP,
SEP,
BEL
].join('');

console.log(table([[link]]));
```

Output:

```sh
╔═══════════════════════════════╗
║ ttps://example.comThis is a link to exa ║
║ ttps://exammple.com ║
╚═══════════════════════════════╝
```

Additionally, if I change the `text` variable to be something shorter, i.e. `foo`, it throws an error:

```sh
Error: Subject parameter value width cannot be greater than the container width.
at alignString (/Users/ericbiewener/Repos/Walmart/github-api/node_modules/table/dist/alignString.js:78:11)
at /Users/ericbiewener/Repos/Walmart/github-api/node_modules/table/dist/alignTableData.js:27:41
at Array.map ()
at /Users/ericbiewener/Repos/Walmart/github-api/node_modules/table/dist/alignTableData.js:21:18
at Array.map ()
at alignTableData (/Users/ericbiewener/Repos/Walmart/github-api/node_modules/table/dist/alignTableData.js:20:15)
at table (/Users/ericbiewener/Repos/Walmart/github-api/node_modules/table/dist/table.js:102:38)
at Object. (/Users/ericbiewener/Repos/Walmart/github-api/src/test.js:24:13)
at Module._compile (internal/modules/cjs/loader.js:759:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
```

From testing, it appears that error gets thrown if `text` is shorter than `url`.

I'm using zsh, node v12.2.0, and OSX 10.15.5.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.