Skip to content

Commit 9b8bd74

Browse files
committed
refactor: drop destr in favor of native JSON.parse
Replace destr with a small JSON.parse helper for parsing the props query in the import plugin. Keeps destr prototype-pollution guard via a reviver that strips __proto__/constructor keys. Removes the destr dependency and catalog entry.
1 parent 23aec72 commit 9b8bd74

4 files changed

Lines changed: 17 additions & 11 deletions

File tree

packages/vuetify-nuxt-module/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
"@vuetify/loader-shared": "catalog:",
8181
"@vuetify/unplugin-styles": "catalog:",
8282
"defu": "catalog:",
83-
"destr": "catalog:",
8483
"local-pkg": "catalog:",
8584
"pathe": "catalog:",
8685
"perfect-debounce": "catalog:",
@@ -131,7 +130,6 @@
131130
"node:child_process",
132131
"node:fs",
133132
"consola",
134-
"destr",
135133
"esbuild",
136134
"local-pkg",
137135
"pathe",

packages/vuetify-nuxt-module/src/vite/vuetify-import-plugin.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import type { Options } from '@vuetify/loader-shared'
22
import type { Plugin } from 'vite'
33
import { pathToFileURL } from 'node:url'
44
import { generateImports } from '@vuetify/loader-shared'
5-
import destr from 'destr'
65
import { isAbsolute } from 'pathe'
76
import { parseQuery, parseURL } from 'ufo'
87
import { createFilter } from 'vite'
@@ -12,10 +11,26 @@ function parseId2 (id: string) {
1211
return parseURL(decodeURIComponent(isAbsolute(id) ? pathToFileURL(id).href : id))
1312
}
1413

14+
function reviver (key: string, value: unknown) {
15+
if (key === '__proto__' || key === 'constructor') {
16+
return undefined
17+
}
18+
return value
19+
}
20+
21+
function parseProps (value: string): Record<string, any> | undefined {
22+
try {
23+
const parsed = JSON.parse(value, reviver)
24+
return parsed && typeof parsed === 'object' ? parsed : undefined
25+
} catch {
26+
return undefined
27+
}
28+
}
29+
1530
function parseId (id: string) {
1631
const { search, pathname } = parseId2(id)
1732
const query = parseQuery(search)
18-
const urlProps = query.props ? destr<Record<string, any>>(query.props as string) : undefined
33+
const urlProps = query.props ? parseProps(query.props as string) : undefined
1934

2035
return {
2136
query: urlProps,

pnpm-lock.yaml

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ catalog:
4646
date-fns-jalali: 2.19.0-2
4747
dayjs: ^1.11.19
4848
defu: ^6.1.4
49-
destr: ^2.0.5
5049
eslint: ^10.0.2
5150
eslint-config-vuetify: 4.3.5-beta.1
5251
local-pkg: ^1.1.2

0 commit comments

Comments
 (0)