Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
var md5 = require('md5');
const SUBSTITUTE_BASE = 'https://example.com/';
const SUBSTITUTE_SECRET = 'a secret';
html = html.replace(/<img[^>]*src=('|")(.*?)\1[^>]*>/g, function(img) {
var src = RegExp.$2;
var digest = md5.hmac(SUBSTITUTE_SECRET, src);
var newSrc = SUBSTITUTE_BASE + digest + '/' + encodeURIComponent(src);
return img.replace(src, newSrc);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.