Skip to content

Commit

Permalink
fix: fix a bug when parsing attributes if no parseHTML method is prov…
Browse files Browse the repository at this point in the history
…ided, fix #2058
  • Loading branch information
philippkuehn committed Nov 8, 2021
1 parent c94d2b0 commit 5da313a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/core/src/utilities/fromString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export default function fromString(value: any): any {
return value
}

if (value.match(/^\d*(\.\d+)?$/)) {
if (value.match(/^[+-]?(?:\d*\.)?\d+$/)) {
return Number(value)
}

Expand Down
6 changes: 6 additions & 0 deletions tests/cypress/integration/core/fromString.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ describe('fromString', () => {
expect(value).to.eq('test')
})

it('should return an empty string', () => {
const value = fromString('')

expect(value).to.eq('')
})

it('should convert to a number', () => {
const value = fromString('1')

Expand Down

0 comments on commit 5da313a

Please sign in to comment.