Skip to content

Commit 984aec5

Browse files
author
Deepak Prabhakara
authored
if audience is truthy but is not a string startWith fails (#822)
1 parent 8bb41f3 commit 984aec5

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

lib/saml20.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,20 @@ const parse = (assertion) => {
107107
const validateAudience = (assertion, realm) => {
108108
const audience = getProp(assertion, 'Conditions.AudienceRestriction.Audience');
109109
if (audience) {
110-
if (Array.isArray(realm)) {
111-
for (let i = 0; i < realm.length; i++) {
112-
if (audience.startsWith(realm[i])) {
113-
return true;
110+
try {
111+
if (Array.isArray(realm)) {
112+
for (let i = 0; i < realm.length; i++) {
113+
if (audience.startsWith(realm[i])) {
114+
return true;
115+
}
114116
}
117+
return false;
115118
}
119+
return audience.startsWith(realm);
120+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
121+
} catch (err) {
116122
return false;
117123
}
118-
return audience.startsWith(realm);
119124
} else {
120125
return false;
121126
}

0 commit comments

Comments
 (0)