Skip to content

Commit 91f6276

Browse files
committed
fix: handle empty profiles
1 parent c29f01d commit 91f6276

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/runtime/plugin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { defineNuxtPlugin } from '#app'
44
import { useRuntimeConfig } from '#imports'
55

66
export default defineNuxtPlugin(async ({ vueApp }) => {
7-
const { public: { dompurify: { profiles } } } = useRuntimeConfig()
7+
const { public: { dompurify } } = useRuntimeConfig()
88

99
let purify: DOMPurify.DOMPurifyI
1010

@@ -17,8 +17,8 @@ export default defineNuxtPlugin(async ({ vueApp }) => {
1717
}
1818

1919
function sanitizeHtml(binding: DirectiveBinding) {
20-
if (binding.arg && profiles[binding.arg]) {
21-
return purify.sanitize(binding.value, profiles[binding.arg])
20+
if (binding.arg && dompurify?.profiles?.[binding.arg]) {
21+
return purify.sanitize(binding.value, dompurify.profiles[binding.arg])
2222
}
2323

2424
return purify.sanitize(binding.value)

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export interface ModuleOptions {
6565
declare module 'nuxt/schema' {
6666
interface PublicRuntimeConfig {
6767
dompurify: {
68-
profiles: Profiles
68+
profiles?: Profiles
6969
}
7070
}
7171
}

0 commit comments

Comments
 (0)