Skip to content

Commit 2d12da6

Browse files
committedOct 6, 2024··
fix: use hash for api key
1 parent 857b2de commit 2d12da6

File tree

3 files changed

+52
-478
lines changed

3 files changed

+52
-478
lines changed
 

Diff for: ‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"fast-glob": "^3.3.2",
5050
"local-pkg": "^0.5.0",
5151
"mlly": "^1.7.1",
52+
"ohash": "^1.1.4",
5253
"pathe": "^1.1.2",
5354
"std-env": "^3.7.0"
5455
},

Diff for: ‎pnpm-lock.yaml

+48-476
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ‎src/runtime/server/api.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { basename } from 'pathe'
22
import { getIcons } from '@iconify/utils'
33
import { consola } from 'consola'
4+
import { hash } from 'ohash'
45
import { createError, getQuery, type H3Event } from 'h3'
56
import type { NuxtIconRuntimeOptions } from '../../schema-types'
67
// @ts-expect-error tsconfig.server has the types
@@ -71,8 +72,8 @@ export default defineCachedEventHandler(async (event: H3Event) => {
7172
name: 'icon',
7273
getKey(event: H3Event) {
7374
const collection = event.context.params?.collection?.replace(/\.json$/, '') || 'unknown'
74-
const icons = String(getQuery(event).icons || '').split(',')
75-
return `${collection}_${icons.join('_')}`
75+
const icons = String(getQuery(event).icons || '')
76+
return `${collection}_${icons.split(',')[0]}_${icons.length}_${hash(icons)}`
7677
},
7778
swr: true,
7879
maxAge: 60 * 60 * 24 * 7, // 1 week

0 commit comments

Comments
 (0)
Please sign in to comment.