2019-12-17 19:27:28 +00:00
|
|
|
import { helper } from '@ember/component/helper';
|
|
|
|
|
2020-09-18 10:14:06 +00:00
|
|
|
export default helper(function routeMatch([item], hash) {
|
2020-09-30 11:33:01 +00:00
|
|
|
const prop = ['Present', 'Exact', 'Prefix', 'Suffix', 'Regex'].find(
|
|
|
|
prop => typeof item[prop] !== 'undefined'
|
|
|
|
);
|
|
|
|
|
|
|
|
switch (prop) {
|
|
|
|
case 'Present':
|
2020-09-18 10:14:06 +00:00
|
|
|
return `${item.Invert ? `NOT ` : ``}present`;
|
2020-09-30 11:33:01 +00:00
|
|
|
case 'Exact':
|
2020-09-18 10:14:06 +00:00
|
|
|
return `${item.Invert ? `NOT ` : ``}exactly matching "${item.Exact}"`;
|
2020-09-30 11:33:01 +00:00
|
|
|
case 'Prefix':
|
2020-09-18 10:14:06 +00:00
|
|
|
return `${item.Invert ? `NOT ` : ``}prefixed by "${item.Prefix}"`;
|
2020-09-30 11:33:01 +00:00
|
|
|
case 'Suffix':
|
2020-09-18 10:14:06 +00:00
|
|
|
return `${item.Invert ? `NOT ` : ``}suffixed by "${item.Suffix}"`;
|
2020-09-30 11:33:01 +00:00
|
|
|
case 'Regex':
|
2020-09-18 10:14:06 +00:00
|
|
|
return `${item.Invert ? `NOT ` : ``}matching the regex "${item.Regex}"`;
|
2019-12-17 19:27:28 +00:00
|
|
|
}
|
|
|
|
return '';
|
|
|
|
});
|