mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Merge pull request #802 from cdparks/fallback-to-regex
Falling back to regex solution for default value when value is malformed
This commit is contained in:
commit
bfddc53034
@ -408,8 +408,12 @@ exports.splitName = function(nameDesc) {
|
||||
// dash as a separator
|
||||
|
||||
// optional values get special treatment
|
||||
var result = null;
|
||||
if (nameDesc[0] === '[') {
|
||||
return splitNameMatchingBrackets(nameDesc);
|
||||
result = splitNameMatchingBrackets(nameDesc);
|
||||
if (result !== null) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
nameDesc.match(REGEXP_NAME_DESCRIPTION);
|
||||
|
||||
@ -264,6 +264,24 @@ describe('jsdoc/name', function() {
|
||||
expect(parts.name).toBe('[path=["Unmatched begin: ["]]');
|
||||
expect(parts.description).toBe('Path split into components');
|
||||
});
|
||||
|
||||
it('should fail gracefully when the default value has an unmatched bracket', function() {
|
||||
var startName = '[path=["home", "user"] - Path split into components'
|
||||
var parts = jsdoc.name.splitName(startName);
|
||||
|
||||
expect(parts).not.toBe(null);
|
||||
expect(parts.name).toBe('[path=["home", "user"]');
|
||||
expect(parts.description).toBe('Path split into components');
|
||||
});
|
||||
|
||||
it('should fail gracefully when the default value has an unmatched quote', function() {
|
||||
var startName = '[path=["home", "user] - Path split into components'
|
||||
var parts = jsdoc.name.splitName(startName);
|
||||
|
||||
expect(parts).not.toBe(null);
|
||||
expect(parts.name).toBe('[path=["home", "user]');
|
||||
expect(parts.description).toBe('Path split into components');
|
||||
});
|
||||
});
|
||||
|
||||
describe('resolve', function() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user