Open theproductiveprogrammer opened 1 year ago
Sometimes the downloaded files are uri-encoded. For example:
https://www.ibm.com/downloads/cas/YE8GYW97
This returns the filename: "'ESG%3A%20Storage%27s%20Role%20in%20Addressing%20the%20Challenges%20of%20Ensuring%20Cyber%20Resilience.pdf"
Using filenamify() on this filename keeps the uri-encoding and truncates the extension as well:
filenamify()
> filenamify('ESG%3A%20Storage%27s%20Role%20in%20Addressing%20the%20Challenges%20of%20Ensuring%20Cyber%20Resilience.pdf') 'ESG%3A%20Storage%27s%20Role%20in%20Addressing%20the%20Challenges%20of%20Ensuring%20Cyber%20Resilienc'
To handle such cases we should decode any url-encodings as I have done in this PR. That cleans up the filename and stores it correctly as well.
Before fix:
download('https://www.ibm.com/downloads/cas/YE8GYW97', 'dist'); // dist/ESG%3A%20Storage%27s%20Role%20in%20Addressing%20the%20Challenges%20of%20Ensuring%20Cyber%20Resilienc
After fix:
download('https://www.ibm.com/downloads/cas/YE8GYW97', 'dist'); // dist/ESG! Storage's Role in Addressing the Challenges of Ensuring Cyber Resilience.pdf
Sometimes the downloaded files are uri-encoded. For example:
https://www.ibm.com/downloads/cas/YE8GYW97
This returns the filename: "'ESG%3A%20Storage%27s%20Role%20in%20Addressing%20the%20Challenges%20of%20Ensuring%20Cyber%20Resilience.pdf"
Using
filenamify()
on this filename keeps the uri-encoding and truncates the extension as well:To handle such cases we should decode any url-encodings as I have done in this PR. That cleans up the filename and stores it correctly as well.
Before fix:
After fix: