Skip to content

Commit

Permalink
Merge pull request #94 from hCaptcha/add_custom_parameter
Browse files Browse the repository at this point in the history
Add custom parameter
  • Loading branch information
kdziamura authored Aug 13, 2021
2 parents a417f22 + dcff54c commit 7ecb2f7
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ In these instances, you'll most likely want to use `ref` to handle the callbacks
|`imghost`|String|No|`-`|See enterprise docs.|
|`reportapi`|String|No|`-`|See enterprise docs.|
|`sentry`|String|No|`-`|See enterprise docs.|
|`custom`|Boolean|No|`-`|See enterprise docs.|

### Events

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hcaptcha/react-hcaptcha",
"version": "0.3.6",
"version": "0.3.7",
"types": "types/index.d.ts",
"main": "dist/index.js",
"files": [
Expand Down
5 changes: 3 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class HCaptcha extends React.Component {
}

componentDidMount () { //Once captcha is mounted intialize hCaptcha - hCaptcha
const { apihost, assethost, endpoint, host, imghost, languageOverride:hl, reCaptchaCompat, reportapi, sentry } = this.props;
const { apihost, assethost, endpoint, host, imghost, languageOverride:hl, reCaptchaCompat, reportapi, sentry, custom } = this.props;
const { isApiReady } = this.state;

if (!isApiReady) { //Check if hCaptcha has already been loaded, if not create script tag and wait to render captcha
Expand All @@ -75,7 +75,8 @@ class HCaptcha extends React.Component {
imghost,
recaptchacompat: reCaptchaCompat === false? "off" : null,
reportapi,
sentry
sentry,
custom
});
}

Expand Down
12 changes: 11 additions & 1 deletion tests/hcaptcha.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,16 @@ describe("hCaptcha", () => {
const scripts = document.querySelectorAll("head > script");

expect(scripts.length).toBe(1);
})
});

it("custom parameter should be in script query", () => {
instance = ReactTestUtils.renderIntoDocument(<HCaptcha
custom={true}
sitekey={TEST_PROPS.sitekey}
/>);

const script = document.querySelector("head > script");
expect(script.src).toContain("custom=true");
});
});
});

0 comments on commit 7ecb2f7

Please sign in to comment.