jakeFeldman / strapi-provider-upload-azure-storage

Strapi Provider Upload Azure Storage
MIT License
75 stars 42 forks source link

`removeCN` option not working for containers with special characters #96

Open AkimaLunar opened 2 months ago

AkimaLunar commented 2 months ago

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.