Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.

Commit 00a7b1b

Browse files
suzanadirlaeromano
authored andcommitted
[ADF-4810] check publicUrls is array object (#423)
1 parent 75c9d1f commit 00a7b1b

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/authentication/oauth2Auth.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,11 @@ export class Oauth2Auth extends AlfrescoApiClient {
259259
isPublicUrl(): boolean {
260260
const publicUrls = this.config.oauth2.publicUrls || [];
261261

262-
return publicUrls.length &&
263-
publicUrls.some((urlPattern: string) => minimatch(window.location.href, urlPattern));
262+
if (Array.isArray(publicUrls)) {
263+
return publicUrls.length &&
264+
publicUrls.some((urlPattern: string) => minimatch(window.location.href, urlPattern));
265+
}
266+
return false;
264267
}
265268

266269
padBase64(base64data: any) {

test/oauth2Auth.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,13 @@ describe('Oauth2 test', function () {
229229
expect(this.oauth2Auth.isPublicUrl()).to.be.equal(false);
230230
});
231231

232+
it('should return `false` if public urls is not set as an array list', function() {
233+
globalAny.window = { location: { href: 'public-url-string'} };
234+
this.oauth2Auth.config.oauth2.publicUrls = 'public-url-string';
235+
236+
expect(this.oauth2Auth.isPublicUrl()).to.be.equal(false);
237+
});
238+
232239
it('should match absolute path', function() {
233240
globalAny.window = { location: { href: 'http://some-public-url'} };
234241
this.oauth2Auth.config.oauth2.publicUrls = ['http://some-public-url'];

0 commit comments

Comments
 (0)