Use substring() instead of substr() (#341)

This commit is contained in:
woxtu
2022-05-13 04:54:35 +09:00
committed by GitHub
parent a3e86f32b7
commit 86eb771cdc

View File

@@ -23,7 +23,7 @@ const loadInterpreter = async function (indexUrl:string): Promise<any> {
// let's get the full path of where PyScript is running from so we can load the pyscript.py
// file from the same location
const loadedScript: HTMLScriptElement = document.querySelector(`script[src$='pyscript.js']`);
const scriptPath = loadedScript.src.substr(0, loadedScript.src.lastIndexOf('/'));
const scriptPath = loadedScript.src.substring(0, loadedScript.src.lastIndexOf('/'));
await pyodide.runPythonAsync(await (await fetch(`${scriptPath}/pyscript.py`)).text());
console.log(scriptPath);