WIP
This commit is contained in:
@@ -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) : "",
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user