-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathio.js
More file actions
27 lines (23 loc) · 685 Bytes
/
Copy pathio.js
File metadata and controls
27 lines (23 loc) · 685 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class IO {
/**
* Estimated "URI too long" limit to use when checking for a URI's length after generating an
* export link.
*/
MAX_URI_LENGTH = 8000;
/**
* Attempts to get the puzzle data from the URL passed in.
*
* @param {string} loadUrl URL to attempt to parse for puzzle data.
*/
getPuzzleDataFromUrl = function (loadUrl) {
const urlAsUrl = new URL(loadUrl);
let puzzleData;
if (loadUrl.includes("#")) {
puzzleData = urlAsUrl.hash.split("#")[1];
} else {
puzzleData = urlAsUrl.search.split("?")[1];
}
return puzzleData;
};
};
const PenpaIO = new IO();