Skip to content

Commit

Permalink
shorten token normalization function body
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtoolz committed Dec 16, 2024
1 parent acd6b04 commit a8655bb
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/pds/src/api/com/atproto/server/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ export const getEmailToken = () => {
// Transforms a badly-formed email token to XXXXX-XXXXX
// (i.e from xxXxxxx-xxx or xxxxxxxxxx)
export const normalizeEmailToken = (input: string): string => {
let normalized = input.trim().toUpperCase() // trim & capitalize
normalized = normalized.replace(/[^A-Z0-9]/g, '') // remove everything that isn't a letter or number
normalized = normalized.slice(0, 5) + '-' + normalized.slice(5, 10) // replace the hyphen
return normalized
}
const normalized = input.trim().toUpperCase().replace('-', ''); // normalize to XXXXXXXXXX
return normalized.slice(0, 5) + '-' + normalized.slice(5, 10); // insert hyphen
};

export const safeResolveDidDoc = async (
ctx: AppContext,
Expand Down

0 comments on commit a8655bb

Please sign in to comment.