Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Sanitize the zone passed in. #102

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/auth/auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,25 @@ describe('Auth', () => {
done();
});
});

it('should convert tokenized urls and honor the hard-coded zone.', (done) => {
BBAuth.getUrl(
'1bb://eng-hub00-pusa01/version'
).then((url: string) => {
expect(url).toBe('https://eng-pusa01.app.blackbaud.net/hub00/version');
done();
});
});

it('should convert tokenized urls and get zone from the token.', (done) => {
BBAuth.getUrl(
'1bb://eng-hub00/version',
{
zone: 'p-can01'
}
).then((url: string) => {
expect(url).toBe('https://eng-pcan01.app.blackbaud.net/hub00/version');
done();
});
});
});
4 changes: 4 additions & 0 deletions src/auth/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ export class BBAuth {
let result = tokenizedUrl;
let zone = args ? args.zone : undefined;

if (zone) {
zone = zone.replace('-', '');
}

if (match) {
if (match[3]) {
zone = match[3].substring(1);
Expand Down