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
2 changes: 1 addition & 1 deletion src/core/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export function createInput<
and: Object.assign((...inputs: InputSource[]) => createInput(`${s}${exactly(...inputs)}`), {
referenceTo: (groupName: string) => createInput(`${s}\\k<${groupName}>`),
}),
or: (...inputs) => createInput(`(?:${s}|${exactly(...inputs)})`),
or: (...inputs) => createInput(`(?:${s}|${inputs.map(v => exactly(v)).join('|')})`),
after: (...input) => createInput(`(?<=${exactly(...input)})${s}`),
before: (...input) => createInput(`${s}(?=${exactly(...input)})`),
notAfter: (...input) => createInput(`(?<!${exactly(...input)})${s}`),
Expand Down
2 changes: 1 addition & 1 deletion test/inputs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ describe('chained inputs', () => {
const multi = multichar.or('foo', input.groupedAs('groupName'), exactly('bar').or(test))
const regexp2 = new RegExp(multi as any)
expect(regexp2).toMatchInlineSnapshot(
'/\\(\\?:ab\\|foo\\(\\?<groupName>\\\\\\?\\)\\(\\?:bar\\|test\\\\\\.js\\)\\)/',
'/\\(\\?:ab\\|foo\\|\\(\\?<groupName>\\\\\\?\\)\\|\\(\\?:bar\\|test\\\\\\.js\\)\\)/',
)
expectTypeOf(
extractRegExp(multi),
Expand Down
Loading