Skip to content

Commit

Permalink
Only change protocol on http https
Browse files Browse the repository at this point in the history
  • Loading branch information
forgetso committed Dec 12, 2024
1 parent f131c3d commit 975afbd
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions packages/procaptcha/src/modules/ProsopoCaptchaApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,17 @@ export class ProsopoCaptchaApi implements ProcaptchaApiInterface {
}

// convert https/http to match page
for (const captcha of captchaChallenge.captchas) {
for (const item of captcha.items) {
if (item.data) {
// drop the 'http(s):' prefix, leaving '//'. The '//' will autodetect http/https from the page load type
// https://stackoverflow.com/a/18320348/7215926
item.data = item.data.replace(/^http(s)*:\/\//, "//");
if (
window.location.protocol === "https:" ||
window.location.protocol === "http:"
) {
for (const captcha of captchaChallenge.captchas) {
for (const item of captcha.items) {
if (item.data) {
// drop the 'http(s):' prefix, leaving '//'. The '//' will autodetect http/https from the page load type
// https://stackoverflow.com/a/18320348/7215926
item.data = item.data.replace(/^http(s)*:\/\//, "//");
}
}
}
}
Expand Down

0 comments on commit 975afbd

Please sign in to comment.