Skip to content

Commit

Permalink
Fix URL replacement in HTML content
Browse files Browse the repository at this point in the history
  • Loading branch information
fnicollet authored Sep 18, 2022
1 parent d058a38 commit b9d865e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/jquery-captcha.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,13 @@

var relativeUrl, relativeUrlPrefixPattern, absoluteUrl,
changedCaptchaHtml = originCaptchaHtml;

for (var i = 0; i < relativeUrls.length; i++) {
relativeUrl = relativeUrls[i].slice(0, -1).replace(/src=\"|href=\"/, '');
relativeUrlPrefixPattern = new RegExp(".*" + captchaEndpointHandler);
absoluteUrl = relativeUrl.replace(relativeUrlPrefixPattern, backendUrl + captchaEndpointHandler);
changedCaptchaHtml = changedCaptchaHtml.replace(relativeUrl, absoluteUrl);
}
var captchaEndpointHandlerWithSeparator = backendUrl + captchaEndpointHandler + (captchaEndpointHandler.indexOf('?') == -1 ? '?' : '&')
for (var i = 0; i < relativeUrls.length; i++) {
relativeUrl = relativeUrls[i].slice(0, -1).replace(/src=\"|href=\"/, '');
relativeUrlPrefixPattern = "/api/simple-captcha-endpoint?";
absoluteUrl = relativeUrl.replace(relativeUrlPrefixPattern, captchaEndpointHandlerWithSeparator);
changedCaptchaHtml = changedCaptchaHtml.replace(relativeUrl, absoluteUrl);
}

return changedCaptchaHtml;
};
Expand Down

0 comments on commit b9d865e

Please sign in to comment.