utils.ts 770 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
export function isUrl(path: string) {
5 6
  return reg.test(path);
}
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
7

้™ˆๅธ…'s avatar
้™ˆๅธ… committed
8
export function 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 13 14 15
  return window.location.hostname === 'preview.pro.ant.design';
}

// ็ป™ๅฎ˜ๆ–นๆผ”็คบ็ซ™็‚น็”จ๏ผŒ็”จไบŽๅ…ณ้—ญ็œŸๅฎžๅผ€ๅ‘็Žฏๅขƒไธ้œ€่ฆไฝฟ็”จ็š„็‰นๆ€ง
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
16
export function 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
}