Skip to content

Commit 2c1e320

Browse files
authored
fix(scripts): remove failed attempts from scripts (#17)
1 parent 421b59e commit 2c1e320

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/src/loader.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,27 @@ export function hCaptchaApi(params: ILoaderParams = { cleanup: true }, sentry: S
7070
data: script
7171
});
7272

73-
hCaptchaScripts.push({ promise, scope: frame.window });
7473
} catch(error) {
7574
sentry.addBreadcrumb({
7675
category: SENTRY_TAG,
7776
message: 'hCaptcha failed to load',
7877
data: error,
7978
});
8079

80+
81+
const scriptIndex = hCaptchaScripts.findIndex(script => script.scope === frame.window);
82+
83+
if (scriptIndex !== -1) {
84+
hCaptchaScripts.splice(scriptIndex, 1);
85+
}
86+
8187
sentry.captureException(error);
8288
reject(new Error(SCRIPT_ERROR));
8389
}
8490
}
8591
);
8692

93+
hCaptchaScripts.push({ promise, scope: frame.window });
8794
return promise;
8895
} catch (error) {
8996
sentry.captureException(error);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@hcaptcha/loader",
33
"description": "This is a JavaScript library to easily configure the loading of the hCaptcha JS client SDK with built-in error handling.",
4-
"version": "1.1.1",
4+
"version": "1.1.2",
55
"author": "hCaptcha team and contributors",
66
"license": "MIT",
77
"keywords": [

0 commit comments

Comments
 (0)