utils.ts 687 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 8 9 10 11 12 13 14 15 16 17 18

// 给官方演示站点用,用于关闭真实开发环境不需要使用的特性
export function isAntDesignProOrDev() {
  const { NODE_ENV } = process.env;
  if (ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site') {
    return true;
  }
  if (NODE_ENV === 'development') {
    return true;
  }
  return window.location.hostname === 'preview.pro.ant.design';
}