Skip to content

Commit

Permalink
fix: handle empty profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
radyakaze committed Oct 3, 2024
1 parent c29f01d commit 91f6276
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/runtime/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { defineNuxtPlugin } from '#app'
import { useRuntimeConfig } from '#imports'

export default defineNuxtPlugin(async ({ vueApp }) => {
const { public: { dompurify: { profiles } } } = useRuntimeConfig()
const { public: { dompurify } } = useRuntimeConfig()

let purify: DOMPurify.DOMPurifyI

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

function sanitizeHtml(binding: DirectiveBinding) {
if (binding.arg && profiles[binding.arg]) {
return purify.sanitize(binding.value, profiles[binding.arg])
if (binding.arg && dompurify?.profiles?.[binding.arg]) {
return purify.sanitize(binding.value, dompurify.profiles[binding.arg])
}

return purify.sanitize(binding.value)
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export interface ModuleOptions {
declare module 'nuxt/schema' {
interface PublicRuntimeConfig {
dompurify: {
profiles: Profiles
profiles?: Profiles
}
}
}
Expand Down

0 comments on commit 91f6276

Please sign in to comment.