We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e496e4c commit 4700593Copy full SHA for 4700593
1 file changed
docs/guide/rule-engines/javascript.md
@@ -62,6 +62,24 @@ r.host === 'facebook.com' ? {deny_message: 'Social media blocked'} : true
62
({allow: {max_tx_bytes: 1024}})
63
```
64
65
+## Using Return Statements
66
+
67
+JavaScript rules don't allow naked `return` statements. To use returns, wrap your code in an IIFE:
68
69
+```javascript
70
+(function() {
71
+ if (r.host === 'github.com') {
72
+ return true;
73
+ }
74
75
+ if (r.host.match(/facebook|twitter/)) {
76
+ return {deny_message: "Blocked"};
77
78
79
+ return false;
80
+})();
81
+```
82
83
## Common Patterns
84
85
### Domain Allowlisting
0 commit comments