2023-03-14 14:18:55 +01:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
2023-08-11 09:12:13 -04:00
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
2023-03-14 14:18:55 +01:00
|
|
|
*/
|
|
|
|
|
2019-12-17 19:27:28 +00:00
|
|
|
import { helper } from '@ember/component/helper';
|
|
|
|
|
2020-09-18 11:14:06 +01:00
|
|
|
export default helper(function routeMatch([item], hash) {
|
2020-09-30 12:33:01 +01:00
|
|
|
const prop = ['Present', 'Exact', 'Prefix', 'Suffix', 'Regex'].find(
|
2022-09-15 10:43:17 +02:00
|
|
|
(prop) => typeof item[prop] !== 'undefined'
|
2020-09-30 12:33:01 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
switch (prop) {
|
|
|
|
case 'Present':
|
2020-09-18 11:14:06 +01:00
|
|
|
return `${item.Invert ? `NOT ` : ``}present`;
|
2020-09-30 12:33:01 +01:00
|
|
|
case 'Exact':
|
2020-09-18 11:14:06 +01:00
|
|
|
return `${item.Invert ? `NOT ` : ``}exactly matching "${item.Exact}"`;
|
2020-09-30 12:33:01 +01:00
|
|
|
case 'Prefix':
|
2020-09-18 11:14:06 +01:00
|
|
|
return `${item.Invert ? `NOT ` : ``}prefixed by "${item.Prefix}"`;
|
2020-09-30 12:33:01 +01:00
|
|
|
case 'Suffix':
|
2020-09-18 11:14:06 +01:00
|
|
|
return `${item.Invert ? `NOT ` : ``}suffixed by "${item.Suffix}"`;
|
2020-09-30 12:33:01 +01:00
|
|
|
case 'Regex':
|
2020-09-18 11:14:06 +01:00
|
|
|
return `${item.Invert ? `NOT ` : ``}matching the regex "${item.Regex}"`;
|
2019-12-17 19:27:28 +00:00
|
|
|
}
|
|
|
|
return '';
|
|
|
|
});
|