Skip to content

Commit

Permalink
fix: handle properties are not only delimited by spaces or quotes (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
kstiehl committed Oct 12, 2023
1 parent 19e408c commit 6cade31
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions utils/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,16 +313,18 @@ export class Parser {
this.#debug(path, "parsing property")

//Property name
let property

const quote = this.#stream.peek()
const delimiter = /["']/.test(quote) ? quote : " "
if (delimiter.trim().length) {
this.#consume(delimiter)
if (/["']/.test(quote)) {
this.#consume(quote)
property = this.#capture({ until: new RegExp(quote), bytes: 1 })
this.#consume(quote)
} else {
property = this.#capture({ until: /[\s>]/, bytes: 1 })
}
const property = this.#capture({ until: new RegExp(delimiter), bytes: delimiter.length })

this.#debug(path, `found property ${property}`)
if (delimiter.trim().length) {
this.#consume(delimiter)
}

//Result
return { [`${schema.property.prefix}${property}`]: true }
Expand Down

0 comments on commit 6cade31

Please sign in to comment.