From af00f3768e420953382654d5076d258f18d8a501 Mon Sep 17 00:00:00 2001 From: Daniel Fernandes <57069381+dannywritescode@users.noreply.github.com> Date: Mon, 7 Jun 2021 18:26:51 +0530 Subject: [PATCH] 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. --- Tone/core/context/ToneAudioBuffer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tone/core/context/ToneAudioBuffer.ts b/Tone/core/context/ToneAudioBuffer.ts index af309208..c1f72439 100644 --- a/Tone/core/context/ToneAudioBuffer.ts +++ b/Tone/core/context/ToneAudioBuffer.ts @@ -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}`); }