Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi committed Mar 13, 2021
1 parent 9677d95 commit fca8fb0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/convert.ts
Expand Up @@ -731,7 +731,7 @@ function convertBlockLiteral(
const punctuatorRange: Range = [cst.header.start, cst.header.end]
ctx.addToken("Punctuator", punctuatorRange)
const text = ctx.code.slice(cst.valueRange!.start, cst.valueRange!.end)
const offset = /^[^\S\r\n]*/.exec(text)![0].length
const offset = /^[^\S\n\r]*/.exec(text)![0].length
const tokenRange: Range = [
cst.valueRange!.start + offset,
cst.valueRange!.end,
Expand Down Expand Up @@ -769,7 +769,7 @@ function convertBlockFolded(
ctx.addToken("Punctuator", punctuatorRange)

const text = ctx.code.slice(cst.valueRange!.start, cst.valueRange!.end)
const offset = /^[^\S\r\n]*/.exec(text)![0].length
const offset = /^[^\S\n\r]*/.exec(text)![0].length
const tokenRange: Range = [
cst.valueRange!.start + offset,
cst.valueRange!.end,
Expand Down
8 changes: 4 additions & 4 deletions src/tags.ts
Expand Up @@ -48,7 +48,7 @@ export const INT: TagResolver<number> = {
tag: "tag:yaml.org,2002:int",
test(str) {
// see https://yaml.org/spec/1.2/spec.html#id2805071
return /^[-+]?\d+$/u.test(str)
return /^[+-]?\d+$/u.test(str)
},
resolve(str) {
return parseInt(str, 10)
Expand All @@ -70,7 +70,7 @@ export const INT_BASE16: TagResolver<number> = {
tag: "tag:yaml.org,2002:int",
test(str) {
// see https://yaml.org/spec/1.2/spec.html#id2805071
return /^0x[\da-fA-F]+$/u.test(str)
return /^0x[\dA-Fa-f]+$/u.test(str)
},
resolve(str) {
return parseInt(str.slice(2), 16)
Expand All @@ -81,7 +81,7 @@ export const FLOAT: TagResolver<number> = {
tag: "tag:yaml.org,2002:float",
test(str) {
// see https://yaml.org/spec/1.2/spec.html#id2805071
return /^[-+]?(\.\d+|\d+(\.\d*)?)([eE][-+]?\d+)?$/u.test(str)
return /^[+-]?(\.\d+|\d+(\.\d*)?)([Ee][+-]?\d+)?$/u.test(str)
},
resolve(str) {
return parseFloat(str)
Expand All @@ -92,7 +92,7 @@ export const INFINITY: TagResolver<number> = {
tag: "tag:yaml.org,2002:float",
test(str) {
// see https://yaml.org/spec/1.2/spec.html#id2805071
return /^[-+]?(\.inf|\.Inf|\.INF)$/u.test(str)
return /^[+-]?(\.inf|\.Inf|\.INF)$/u.test(str)
},
resolve(str) {
return str.startsWith("-") ? -Infinity : Infinity
Expand Down

0 comments on commit fca8fb0

Please sign in to comment.