File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { basename } from 'pathe'
22import { getIcons } from '@iconify/utils'
33import { consola } from 'consola'
44import { useAppConfig , defineCachedEventHandler } from 'nitropack/runtime'
5+ import { createError } from 'h3'
56import type { NuxtIconRuntimeOptions } from '../../schema-types'
67import { collections } from '#nuxt-icon-server-bundle'
78
@@ -21,7 +22,7 @@ export default defineCachedEventHandler(async (ctx) => {
2122 : null
2223
2324 const apiEndPoint = options . iconifyApiEndpoint || DEFAULT_ENDPOINT
24- const apiUrl = new URL ( basename ( url ) , apiEndPoint )
25+ const apiUrl = new URL ( './' + basename ( url ) , apiEndPoint )
2526 const icons = apiUrl . searchParams . get ( 'icons' ) ?. split ( ',' )
2627
2728 if ( collection ) {
@@ -47,6 +48,9 @@ export default defineCachedEventHandler(async (ctx) => {
4748
4849 if ( options . fallbackToApi ) {
4950 consola . debug ( `[Icon] fetching ${ ( icons || [ ] ) . map ( i => '`' + collectionName + ':' + i + '`' ) . join ( ',' ) } from iconify api` )
51+ if ( apiUrl . host !== new URL ( apiEndPoint ) . host ) {
52+ return createError ( { status : 400 , message : 'Invalid icon request' } )
53+ }
5054 const data = await $fetch ( apiUrl . href )
5155 return data
5256 }
You can’t perform that action at this time.
0 commit comments