strapi-provider-upload-azure-storage icon indicating copy to clipboard operation
strapi-provider-upload-azure-storage copied to clipboard

`removeCN` option not working for containers with special characters

Open AkimaLunar opened this issue 6 months ago • 0 comments

Hello! I am uploading files into a container dedicated for static sites on Azure Storage—$web. Looking at this line, I think I see why $web is not being removed from the final CDN path: even though the container name is $web it gets escaped in the URL string to %24web and hence there is no match.

I would imagine simply passing config.containerName through encodeURIComponent() should fix the issue.

const escapedContainerName = encodeURIComponent(config.containerName);

file.url = file.url.replace(`/${escapedContainerName}/`, '/');

If containerName doesn’t have any special characters, it would just return the same exact string.

Open to contributing!


P.S. I tried using an escaped string in containerName (%24web) and got an upload error.

AkimaLunar avatar Aug 22 '24 00:08 AkimaLunar