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

Deprecate placeholders #13

Merged
merged 1 commit into from
Dec 10, 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
13 changes: 0 additions & 13 deletions lib/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
'&': '&',
'<': '&lt;',
Expand Down Expand Up @@ -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.');
}
Expand All @@ -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
*/
Expand Down
2 changes: 1 addition & 1 deletion test/spec/UtilsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.'));
});

Expand Down
20 changes: 8 additions & 12 deletions test/spec/provider/dmn/IdSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');
Expand All @@ -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');
Expand All @@ -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');
Expand All @@ -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');
});


Expand Down