Skip to content

Commit

Permalink
fix #720
Browse files Browse the repository at this point in the history
  • Loading branch information
errorx666 committed Jul 21, 2018
1 parent 41cb52e commit 4a49247
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export function validateCouchDBString(name) {
) return true;


const regStr = '^[a-z][a-z0-9]*$';
const regStr = '^[a-z][_$a-z0-9]*$';
const reg = new RegExp(regStr);
if (!name.match(reg)) {
throw new RxError.newRxError('UT2', {
Expand Down
9 changes: 9 additions & 0 deletions test/unit/util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ describe('util.test.js', () => {
it('should validate a normal string', () => {
util.validateCouchDBString('foobar');
});
it('should allow _ and $ after the first character', () => {
util.validateCouchDBString('foo_bar');
util.validateCouchDBString('foobar_');
util.validateCouchDBString('foobar$');
} );
it('should not allow _ and $ as first character', () => {
assert.throws( () => util.validateCouchDBString('$foobar'), { code: 'UT2' } );
assert.throws( () => util.validateCouchDBString('_foobar'), { code: 'UT2' } );
} );
it('should validate foldernames', () => {
util.validateCouchDBString('./foobar'); // unix
util.validateCouchDBString('.\\foobar'); //windows
Expand Down

0 comments on commit 4a49247

Please sign in to comment.