Skip to content

Commit 2b73484

Browse files
committed
Add an optional "lenient" access mode for claims
Makes #at: return nil for absent keys rather than raising an error, similar to how it works in JavaScript itself
1 parent 31c6b20 commit 2b73484

5 files changed

Lines changed: 17 additions & 4 deletions

File tree

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
accessing - basic
2-
at: aString
3-
^ claims at: aString
2+
at: aString
3+
4+
^ strict
5+
ifTrue: [ claims at: aString ]
6+
ifFalse: [ claims at: aString ifAbsent: [ ] ]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
public
2+
beLenient
3+
4+
strict := false
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
public
2+
beStrict
3+
4+
strict := true
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
initialize
22
initialize
33
super initialize.
4-
claims := Dictionary new.
4+
claims := Dictionary new.
5+
strict := true

source/JSONWebToken-Core.package/JWTClaimsSet.class/properties.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"pools" : [ ],
77
"classvars" : [ ],
88
"instvars" : [
9-
"claims"
9+
"claims",
10+
"strict"
1011
],
1112
"name" : "JWTClaimsSet",
1213
"type" : "normal"

0 commit comments

Comments
 (0)