Open Jaifroid opened 9 months ago
Actually, it's not yet in core-js 3. It's scheduled for 4 (a proposal).
We can get a polyfill like this:
npm install --save es6-string.prototype.replaceall
And where needed:
import 'es6-string.prototype.replaceall';
(although we probably need import '../../../node_modules/xxxx/dist/xxxx/xxxx.js';
).
This would have to be added to the dependency grid. See https://github.com/kiwix/kiwix-js/blob/main/ADDING_DEPENDENCIES_NODE_MODULES.md for the method to do this.
@Rishabhg71 This is one that could interest you, as it could effectively fix your library feature for a wider range of browsers.
Will it be possible to "artificially" define a string.prototype.replaceAll method in the global scope of the program as a temporary fix for this issue until the release?
Will it be possible to "artificially" define a string.prototype.replaceAll method in the global scope of the program as a temporary fix for this issue until the release?
@Greeshmanth1909 I'll entertain any appropriate fix! We're probably a couple of weeks away from releasing v4.0, and it would certainly be good to get this fixed before that release. I don't think replaceAll should be too hard to emulate, and a full polyfill may be overkill.
@Greeshmanth1909 has discovered that this cannot be polyfilled in Kiwix JS due to CORS. However, it could be fixed upstream in kiwix-tools.
replaceAll()
is used to construct the magnet link, and this throws an error in browser < Chrome/Edge 85 and Firefox 77. To be clear, this error only surfaces when you try to download a file. But as this is the whole point of the library, it really needs to be fixed...See https://caniuse.com/?search=replaceAll.
We should probably polyfill that anyway, as the polyfill is available in core-js.