This commit is contained in:
Maciej Caderek
2022-03-31 22:38:35 +02:00
parent 276c8d221f
commit a003ab6089
5 changed files with 71 additions and 29 deletions

View File

@@ -1,25 +1,25 @@
import { decompressPGN } from "../game/PGNHelpers";
// import { decompressPGN } from "../game/PGNHelpers";
const HEADER_REGEX = /^#(pgn|fen)\//;
// const HEADER_REGEX = /^#(pgn|fen)\//;
const extractUrlData = () => {
const hash = window.location.hash;
// const extractUrlData = () => {
// const hash = window.location.hash;
if (!HEADER_REGEX.test(hash)) {
return {
pgn: "",
fen: "",
};
}
// if (!HEADER_REGEX.test(hash)) {
// return {
// pgn: "",
// fen: "",
// };
// }
const [format, ...chunks] = hash.slice(1).split("/");
// const [format, ...chunks] = hash.slice(1).split("/");
const data = chunks.join("/");
// const data = chunks.join("/");
return {
pgn: format === "pgn" ? decompressPGN(data) : "",
fen: format === "fen" ? decodeURI(data) : "",
};
};
// return {
// pgn: format === "pgn" ? decompressPGN(data) : "",
// fen: format === "fen" ? decodeURI(data) : "",
// };
// };
export default extractUrlData;
// export default extractUrlData;