fix loading of files with special chars in name

file names with special symbols like "C#5.wav" would not get parsed correctly. used encodeURIComponent() for each level of the file path to fix that.
This commit is contained in:
Daniel Fernandes 2021-06-07 18:26:51 +05:30 committed by GitHub
parent a2a13dfe51
commit af00f3768e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -372,7 +372,7 @@ export class ToneAudioBuffer extends Tone {
// make sure there is a slash between the baseUrl and the url
const baseUrl = ToneAudioBuffer.baseUrl === "" || ToneAudioBuffer.baseUrl.endsWith("/") ? ToneAudioBuffer.baseUrl : ToneAudioBuffer.baseUrl + "/";
const response = await fetch(baseUrl + url);
const response = await fetch((baseUrl + url).split("/").map(encodeURIComponent).join("/"));
if (!response.ok) {
throw new Error(`could not load url: ${url}`);
}