mirror of
https://github.com/datahub-project/datahub.git
synced 2025-07-21 16:42:16 +00:00
24 lines
698 B
TypeScript
24 lines
698 B
TypeScript
![]() |
/**
|
||
|
* Matches a string that is prefixed by [platform and suffixed by ]
|
||
|
* Captures the match in the sole capture group
|
||
|
* @type {RegExp}
|
||
|
*/
|
||
|
const platformRegex = /\[platform=([^]]*)]/;
|
||
|
|
||
|
/**
|
||
|
* Checks that a string represents a dataset platform
|
||
|
* @param {string} candidate
|
||
|
* @returns {boolean}
|
||
|
*/
|
||
|
const isDatasetPlatform = (candidate: string): boolean => platformRegex.test(candidate);
|
||
|
|
||
|
/**
|
||
|
* Checks that a string represents a dataset prefix
|
||
|
* @param {string} candidate
|
||
|
* @returns {boolean}
|
||
|
*/
|
||
|
const isDatasetPrefix = (candidate: string): boolean =>
|
||
|
!isDatasetPlatform(candidate) && ['.', '/'].includes(candidate.slice(-1));
|
||
|
|
||
|
export { platformRegex, isDatasetPlatform, isDatasetPrefix };
|