2023-03-14 13:18:55 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
2023-08-11 13:12:13 +00:00
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
2023-03-14 13:18:55 +00:00
|
|
|
*/
|
|
|
|
|
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(
|
2022-09-15 08:43:17 +00:00
|
|
|
(prop) => typeof item[prop] !== 'undefined'
|
2020-09-30 11:33:01 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
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 '';
|
|
|
|
});
|