Skip to content

Commit

Permalink
fix(nanoid): use new customAlphabet api
Browse files Browse the repository at this point in the history
  • Loading branch information
yong-jie committed Apr 7, 2022
1 parent e6945eb commit 805f30e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/client/app/util/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { customAlphabet } from 'nanoid/async'

const ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz'
const LENGTH = 6
const generate = customAlphabet(ALPHABET, LENGTH)

/**
* Generate a random short URL.
Expand All @@ -10,7 +11,7 @@ const LENGTH = 6
* (1e6 / (36^6) = 0.000459, or one in 2176.
*/
export async function generateShortUrl() {
return customAlphabet(ALPHABET, LENGTH)
return generate()
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import generate from 'nanoid/async/generate'
import { customAlphabet } from 'nanoid/async'
import { CookieArrayReducerService } from '..'
import { cookieSessionMaxSizeBytes } from '../../../../config'

const ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz'
const LENGTH = 6
const generate = customAlphabet(ALPHABET, LENGTH)

async function generateShortUrl() {
return generate(ALPHABET, LENGTH)
return generate()
}

const service = new CookieArrayReducerService()
Expand Down

0 comments on commit 805f30e

Please sign in to comment.