Comparing version 0.13.1 to 0.13.2
47
chess.js
@@ -1614,9 +1614,2 @@ /* | ||
function has_keys(object) { | ||
for (var key in object) { | ||
return true | ||
} | ||
return false | ||
} | ||
function parse_pgn_header(header, options) { | ||
@@ -1634,4 +1627,5 @@ var newline_char = | ||
for (var i = 0; i < headers.length; i++) { | ||
key = headers[i].replace(/^\[([A-Z][A-Za-z]*)\s.*\]$/, '$1') | ||
value = headers[i].replace(/^\[[A-Za-z]+\s"(.*)"\ *\]$/, '$1') | ||
var regex = /^\s*\[([A-Za-z]+)\s*"(.*)"\s*\]\s*$/ | ||
key = headers[i].replace(regex, '$1') | ||
value = headers[i].replace(regex, '$2') | ||
if (trim(key).length > 0) { | ||
@@ -1645,2 +1639,5 @@ header_obj[key] = value | ||
// strip whitespace from head/tail of PGN block | ||
pgn = pgn.trim() | ||
var newline_char = | ||
@@ -1653,3 +1650,3 @@ typeof options === 'object' && typeof options.newline_char === 'string' | ||
// will always have a blank line between them (ie, two newline_char's). | ||
// With default newline_char, will equal: /^(\[((?:\r?\n)|.)*\])(?:\r?\n){2}/ | ||
// With default newline_char, will equal: /^(\[((?:\r?\n)|.)*\])(?:\s*\r?\n){2}/ | ||
var header_regex = new RegExp( | ||
@@ -1659,3 +1656,3 @@ '^(\\[((?:' + | ||
')|.)*\\])' + | ||
'(?:' + | ||
'(?:\\s*' + | ||
mask(newline_char) + | ||
@@ -1675,13 +1672,29 @@ '){2}' | ||
var headers = parse_pgn_header(header_string, options) | ||
var fen = '' | ||
for (var key in headers) { | ||
// check to see user is including fen (possibly with wrong tag case) | ||
if (key.toLowerCase() === 'fen') { | ||
fen = headers[key] | ||
} | ||
set_header([key, headers[key]]) | ||
} | ||
/* load the starting position indicated by [Setup '1'] and | ||
* [FEN position] */ | ||
if (headers['SetUp'] === '1') { | ||
if (!('FEN' in headers && load(headers['FEN'], true))) { | ||
// second argument to load: don't clear the headers | ||
return false | ||
/* sloppy parser should attempt to load a fen tag, even if it's | ||
* the wrong case and doesn't include a corresponding [SetUp "1"] tag */ | ||
if (sloppy) { | ||
if (fen) { | ||
if (!load(fen, true)) { | ||
return false | ||
} | ||
} | ||
} else { | ||
/* strict parser - load the starting position indicated by [Setup '1'] | ||
* and [FEN position] */ | ||
if (headers['SetUp'] === '1') { | ||
if (!('FEN' in headers && load(headers['FEN'], true))) { | ||
// second argument to load: don't clear the headers | ||
return false | ||
} | ||
} | ||
} | ||
@@ -1688,0 +1701,0 @@ |
{ | ||
"name": "chess.js", | ||
"version": "0.13.1", | ||
"version": "0.13.2", | ||
"license": "BSD-2-Clause", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
167196
4674