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

duanledexianxianxian's avatar
duanledexianxianxian committed
6 7 8
/**
 * ๆ˜ฏๅฆไธบantd design pro
 */
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
9
const isAntDesignPro = (): boolean => {
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
10 11 12
  if (ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site') {
    return true;
  }
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
13
  return window.location.hostname === 'preview.pro.ant.design';
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
14
};
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
15 16

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

export { isAntDesignProOrDev, isAntDesignPro, isUrl };