diff --git a/src/doc/directives.ts b/src/doc/directives.ts index add18fcd..1b152996 100644 --- a/src/doc/directives.ts +++ b/src/doc/directives.ts @@ -143,7 +143,7 @@ export class Directives { return verbatim } - const [, handle, suffix] = source.match(/^(.*!)([^!]*)$/) as string[] + const [, handle, suffix] = source.match(/^(.*!)([^!]*)$/s) as string[] if (!suffix) onError(`The ${source} tag has no suffix`) const prefix = this.tags[handle] if (prefix) { diff --git a/tests/doc/types.ts b/tests/doc/types.ts index 28f2180b..7646f303 100644 --- a/tests/doc/types.ts +++ b/tests/doc/types.ts @@ -112,6 +112,12 @@ describe('tags', () => { expect(doc.errors).toHaveLength(1) expect(doc.errors[0].message).toMatch('URIError') }) + + test('CR in tag shorthand (eemeli/yaml#501', () => { + const doc = parseDocument(': | !\r!') + const err = doc.errors.find(err => err.code === 'TAG_RESOLVE_FAILED') + expect(err).not.toBeFalsy() + }) }) test('eemeli/yaml#97', () => {