Description
github-default-branch/src/update-content.js
Lines 29 to 30 in 9dda054
var re = new RegExp(r.from, "g");
It should be something like:
var re = new RegExp(escapeRegExpPattern(r.from), "g");
Otherwise, for example, any special RegExp characters such as .
or ?
in the input are not interpreted as the raw characters anymore. As a result the ${owner}/${repo}.svg?branch=${old}
replacement currently does not work.
An example escapeRegExpPattern
implementation can be found here: https://stackoverflow.com/a/9310752/96656
You could also use this String.prototype.replaceAll
polyfill: https://github.com/es-shims/String.prototype.replaceAll (And then in the future, remove it once all Node.js versions you care about get native support.) That way, you don't have to bother converting the search strings into regular expressions just to do global replacement.