This commit is contained in:
Maciej Caderek
2022-02-20 23:36:33 +01:00
parent 5de734392c
commit 9561b0cbf6
5 changed files with 31 additions and 12 deletions

View File

@@ -1,6 +1,6 @@
import { decompressPGN } from "../game/PGNHelpers";
const HEADER_REGEX = /^#v\d+\/(pgn|fen)\//;
const HEADER_REGEX = /^#(pgn|fen)\//;
const extractUrlData = () => {
const hash = window.location.hash;
@@ -12,13 +12,11 @@ const extractUrlData = () => {
};
}
const [rawVersion, format, ...chunks] = hash.split("/");
const [format, ...chunks] = hash.slice(1).split("/");
const version = Number((rawVersion.match(/\d+/g) ?? [])[0]);
const data = chunks.join("/");
return {
version,
pgn: format === "pgn" ? decompressPGN(data) : "",
fen: format === "fen" ? decodeURI(data) : "",
};