utils.ts 826 Bytes
Newer Older
1
/* eslint no-useless-escape:0 import/prefer-default-export:0 */
2
const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;
3

้™ˆๅธ…'s avatar
้™ˆๅธ… committed
4
const isUrl = (path: string): boolean => {
5
  return reg.test(path);
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
6
};
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
7

้™ˆๅธ…'s avatar
้™ˆๅธ… committed
8
const isAntDesignPro = (): boolean => {
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
9 10 11
  if (ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site') {
    return true;
  }
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
12
  return window.location.hostname === 'preview.pro.ant.design';
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
13
};
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
14 15

// ็ป™ๅฎ˜ๆ–นๆผ”็คบ็ซ™็‚น็”จ๏ผŒ็”จไบŽๅ…ณ้—ญ็œŸๅฎžๅผ€ๅ‘็Žฏๅขƒไธ้œ€่ฆไฝฟ็”จ็š„็‰นๆ€ง
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
16
const isAntDesignProOrDev = (): boolean => {
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
17
  const { NODE_ENV } = process.env;
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
18 19 20
  if (NODE_ENV === 'development') {
    return true;
  }
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
21
  return isAntDesignPro();
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
22 23 24
};

export { isAntDesignProOrDev, isAntDesignPro, isUrl };