Closed nickspoons closed 4 years ago
string.replace(...) only replaces the first match when the pattern is a literal string (as opposed to a regular expression), see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace
string.replace(...)
This patch uses string.split(...).join('') instead to ensure all instances of baseUrl are correctly removed from rendered pages.
string.split(...).join('')
An alternative could be to convert the pattern to a regular expression and use the 'g' flag:
const cleanedUpHtml = html.replace(new RegExp(baseUrl, 'g'), '')
However I think this version is simpler and clearer.
You're welcome! Thanks for the project!
string.replace(...)
only replaces the first match when the pattern is a literal string (as opposed to a regular expression), see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceThis patch uses
string.split(...).join('')
instead to ensure all instances of baseUrl are correctly removed from rendered pages.An alternative could be to convert the pattern to a regular expression and use the 'g' flag:
However I think this version is simpler and clearer.