utils.ts 812 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

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

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

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

export { isAntDesignProOrDev, isAntDesignPro, isUrl };