diff --git a/lib/Utils.js b/lib/Utils.js index 93e32c1..5eff1eb 100644 --- a/lib/Utils.js +++ b/lib/Utils.js @@ -18,8 +18,6 @@ var QNAME_REGEX = /^([a-z][\w-.]*:)?[a-z_][\w-.]*$/i; // for ID validation as per BPMN Schema (QName - Namespace) var ID_REGEX = /^[a-z_][\w-.]*$/i; -var PLACEHOLDER_REGEX = /\$\{([^}]*)\}/g; - var HTML_ESCAPE_MAP = { '&': '&', '<': '<', @@ -152,8 +150,6 @@ export function isIdValid(bo, idValue, translate) { export function validateId(idValue, translate) { - idValue = stripPlaceholders(idValue); - if (containsSpace(idValue)) { return translate('Id must not contain spaces.'); } @@ -173,15 +169,6 @@ export function containsSpace(value) { return SPACE_REGEX.test(value); } - -function stripPlaceholders(idValue) { - - // replace expression e.g. ${VERSION_TAG} - // use only the content between ${} - // for the REGEX check - return idValue.replace(PLACEHOLDER_REGEX, '$1'); -} - /** * generate a semantic id with given prefix */ diff --git a/test/spec/UtilsSpec.js b/test/spec/UtilsSpec.js index 082bf1b..f59dde7 100644 --- a/test/spec/UtilsSpec.js +++ b/test/spec/UtilsSpec.js @@ -38,7 +38,7 @@ describe('Utils', function() { it('may NOT start with numbers', validate('9ba', 'Id must be a valid QName.')); it('may NOT start prefix with numbers', validate('9ba:foo', 'Id must be a valid QName.')); - it('may contain ${} placeholders', validate('${foo}ba99')); + it('may NOT contain ${} placeholders', validate('${foo}ba99', 'Id must be a valid QName.')); it('may NOT contain empty placeholders', validate('${}', 'Id must be a valid QName.')); }); diff --git a/test/spec/provider/dmn/IdSpec.js b/test/spec/provider/dmn/IdSpec.js index 08f825a..b649a55 100644 --- a/test/spec/provider/dmn/IdSpec.js +++ b/test/spec/provider/dmn/IdSpec.js @@ -137,7 +137,7 @@ describe('id-properties', function() { })); - it('should set the id with the expression at the beginning', function() { + it('should not set the id with the expression at the beginning', function() { // assume expect(textField.value).to.equal('dish-decision'); @@ -146,12 +146,11 @@ describe('id-properties', function() { triggerValue(textField, '${VERSION_TAG}_foo', 'change'); // then - expect(getTextField().value).to.equal('${VERSION_TAG}_foo'); - expect(businessObject.get('id')).to.equal('${VERSION_TAG}_foo'); + expect(businessObject.get('id')).to.equal('dish-decision'); }); - it('should set the id with the expression at the end', function() { + it('should not set the id with the expression at the end', function() { // assume expect(textField.value).to.equal('dish-decision'); @@ -160,12 +159,11 @@ describe('id-properties', function() { triggerValue(textField, 'foo_${VERSION_TAG}', 'change'); // then - expect(getTextField().value).to.equal('foo_${VERSION_TAG}'); - expect(businessObject.get('id')).to.equal('foo_${VERSION_TAG}'); + expect(businessObject.get('id')).to.equal('dish-decision'); }); - it('should set the id with the expression in the middle', function() { + it('should not set the id with the expression in the middle', function() { // assume expect(textField.value).to.equal('dish-decision'); @@ -174,12 +172,11 @@ describe('id-properties', function() { triggerValue(textField, 'foo_${VERSION_TAG}_bar', 'change'); // then - expect(getTextField().value).to.equal('foo_${VERSION_TAG}_bar'); - expect(businessObject.get('id')).to.equal('foo_${VERSION_TAG}_bar'); + expect(businessObject.get('id')).to.equal('dish-decision'); }); - it('should set the id which is only an expression', function() { + it('should not set the id which is only an expression', function() { // assume expect(textField.value).to.equal('dish-decision'); @@ -188,8 +185,7 @@ describe('id-properties', function() { triggerValue(textField, '${VERSION_TAG}', 'change'); // then - expect(getTextField().value).to.equal('${VERSION_TAG}'); - expect(businessObject.get('id')).to.equal('${VERSION_TAG}'); + expect(businessObject.get('id')).to.equal('dish-decision'); });