Skip to content

storage.keys() on prefixStorage always returns global keys #654

@mattmess1221

Description

@mattmess1221

Environment

N/a

Reproduction

N/a

Describe the bug

When using a prefixStorage object, the aliases (keys, get, set, etc) just keys still point to the original storage object.

unstorage/src/storage.ts

Lines 474 to 481 in 1e3082d

// Aliases
keys: (base, opts = {}) => storage.getKeys(base, opts),
get: (key: string, opts = {}) => storage.getItem(key, opts),
set: (key: string, value: T, opts = {}) =>
storage.setItem(key, value, opts),
has: (key: string, opts = {}) => storage.hasItem(key, opts),
del: (key: string, opts = {}) => storage.removeItem(key, opts),
remove: (key: string, opts = {}) => storage.removeItem(key, opts),

prefixStorage copies the object, but doesn't replace these alias functions.

Additional context

No response

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions