fix tests

This commit is contained in:
Svante Bengtson 2021-07-12 16:26:26 +00:00
parent 4841f73de0
commit 73bd703599
3 changed files with 5 additions and 4 deletions

View File

@ -1,3 +1,3 @@
export const TAG_UNESCAPED = ['\\', ' ', ';', '\r', '\n']
export const TAG_UNESCAPED_REGEX = [/\\\\/g, / /g, /;/g, /\r/g, /\n/g]
export const TAG_UNESCAPED_REGEX = [/\\/g, / /g, /;/g, /\r/g, /\n/g]
export const TAG_ESCAPED = ['\\\\', '\\s', '\\:', '\\r', '\\n']

View File

@ -33,7 +33,7 @@ export function format ({ tags, source, command, params }: FormatArgs) {
outs.push(command)
if (params) {
if (params?.length) {
const paramCopy = [...params]
let last = paramCopy.pop()

View File

@ -56,8 +56,9 @@ export class Line {
}
}
function unescapeTag (value: string) {
function unescapeTag (value?: string) {
let unescaped = ''
if (!value) return unescaped
const escaped = value.split('')
while (escaped.length) {
const current = escaped.shift() as string
@ -102,7 +103,7 @@ function _tokenise (line: string) {
if (!params.length) throw TypeError('Cannot tokenise command-less line')
const command = (params.shift() as string).toLocaleUpperCase()
if (trailing) params.push(trailing)
if (typeof trailing === 'string') params.push(trailing)
return new Line({
tags,