Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport: restore support of empty prefix option #185

Merged
merged 1 commit into from
Nov 29, 2019
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function Level (location, opts) {
}

this.location = location
this.prefix = opts.prefix || DEFAULT_PREFIX
this.prefix = opts.prefix == null ? DEFAULT_PREFIX : opts.prefix
this.version = parseInt(opts.version || 1, 10)
}

Expand Down
21 changes: 21 additions & 0 deletions test/custom-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,27 @@ module.exports = function (leveljs, test, testCommon) {
})
})

test('empty prefix', function (t) {
var db = testCommon.factory({ prefix: '' })

t.ok(db.location, 'instance has location property')
t.is(db.prefix, '', 'instance has prefix property')

db.open(function (err) {
t.notOk(err, 'no open error')

var idb = db.db
var databaseName = idb.name
var storeNames = idb.objectStoreNames

t.is(databaseName, db.location, 'database name is prefixed')
t.is(storeNames.length, 1, 'created 1 object store')
t.is(storeNames.item(0), db.location, 'object store name equals location')

db.close(t.end.bind(t))
})
})

test('put Buffer value, get Buffer value', function (t) {
var level = testCommon.factory()
level.open(function (err) {
Expand Down
4 changes: 3 additions & 1 deletion test/structured-clone-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ var types = [

// Types that are not supported by the structured clone algorithm
var illegalTypes = [
{ name: 'Error', value: new Error() },
// Latest Chrome does seem to support Error, so skip this test.
// { name: 'Error', value: new Error() },

{ name: 'Function', value: function () {} },
{ name: 'DOMNode', value: global.document }
]
Expand Down