robustness: if `prefix` of `content` ends with "/", make sure `replace` ends with "/" too (unless it is empty).