-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ensure all of + and / are replaced to - and _ not only the first occu…
…rances; closes issue #2
- Loading branch information
1 parent
1cf1fb3
commit 095713a
Showing
3 changed files
with
8 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
export function urlsafe_b64encode(data: string): string { | ||
return Buffer.from(data, 'utf-8').toString('base64').replace('+', '-').replace('/', '_').replace(/=+$/, ''); | ||
return Buffer.from(data, 'utf-8').toString('base64') | ||
.replace(/\+/g, '-') // Replace all instances of '+' with '-' | ||
.replace(/\//g, '_') // Replace all instances of '/' with '_' | ||
.replace(/=+$/, ''); // Remove trailing '=' characters | ||
} |