Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion client-src/overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

import ansiHTML from './utils/ansiHTML.js';

const getCodePoint = !!String.prototype.codePointAt
const hasCodePointAt = typeof String.prototype.codePointAt === 'function';
const getCodePoint = hasCodePointAt
? (input: string, position: number): number | undefined =>
input.codePointAt(position)
: (input: string, position: number): number | undefined =>
Expand Down
6 changes: 5 additions & 1 deletion client-src/utils/ansiHTML.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Match = {

// Reference to https://github.com/sindresorhus/ansi-regex
const _regANSI =
// eslint-disable-next-line no-control-regex
/(?:(?:\u001b\[)|\u009b)(?:(?:[0-9]{1,3})?(?:(?:;[0-9]{0,3})*)?[A-M|f-m])|\u001b[A-M]/;

const _defColors: Record<string, string | Array<string>> = {
Expand Down Expand Up @@ -138,6 +139,7 @@ export default function ansiHTML(text: string) {
const ansiCodes: string[] = [];
// Replace with markup.
let ret = text.replace(
// eslint-disable-next-line no-control-regex
/\x1b\[(?:[0-9]{1,3})?(?:(?:;[0-9]{0,3})*)?m/g,
(m) => {
const match = m.match(/(;?\d+)/g)?.map(normalizeSeq) as unknown as Match;
Expand Down Expand Up @@ -211,7 +213,9 @@ ansiHTML.setColors = (colors: typeof _defColors) => {

const _finalColors: typeof _defColors = {};
for (const key in _defColors) {
let hex = colors.hasOwnProperty(key) ? colors[key] : null;
let hex = Object.prototype.hasOwnProperty.call(colors, key)
? colors[key]
: null;
if (!hex) {
_finalColors[key] = _defColors[key];
continue;
Expand Down
Loading