Skip to content

Commit

Permalink
the replace function will only replace the first instance of the + an…
Browse files Browse the repository at this point in the history
…d / characters resulting in some strings that still contain those characters. Altering the string format to base64url will handle everything for url safety automatically. (#31)

#28
  • Loading branch information
driverjb authored Mar 18, 2024
1 parent d08d04d commit 40c2b9f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { randomBytes } from 'crypto';

function bytesToBase64url(s: Buffer): string {
return s.toString('base64').replace('+', '-').replace('/', '_');
return s.toString('base64url');
}

export const generateRandomString = (length: number): string => {
Expand Down

0 comments on commit 40c2b9f

Please sign in to comment.