Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/downgrader/src/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export function isRecord(value: unknown): value is Record<string, unknown> {
const proto: unknown = Object.getPrototypeOf(value)
return (
proto === null ||
proto === Object.prototype ||
(Object.getPrototypeOf(proto) === null && Object.keys(proto as object).length === 0)
)
}
Expand Down Expand Up @@ -192,7 +193,7 @@ function find(root: unknown, ref: string): unknown {
}
let pointer: string
try {
pointer = decodeURIComponent(ref.slice(1))
pointer = ref.includes('%') ? decodeURIComponent(ref.slice(1)) : ref.slice(1)
} catch {
return undefined
}
Expand All @@ -201,7 +202,7 @@ function find(root: unknown, ref: string): unknown {
}
let target = root
for (const token of pointer.split('/').slice(1)) {
const key = token.replaceAll('~1', '/').replaceAll('~0', '~')
const key = token.includes('~') ? token.replaceAll('~1', '/').replaceAll('~0', '~') : token
if (!(isRecord(target) || Array.isArray(target)) || !Object.hasOwn(target, key)) {
return undefined
}
Expand Down
Loading