
const IN_STATION_LINK = []// 站内链接
export const findHyperlinks = (text) => {
  try {
    const urlPattern = /https?:\/\/[^\s]+/g;
    if (!text.match(urlPattern)) return null
    const maybeUrl = text.match(urlPattern)[0];
    const url = new URL(maybeUrl);
    let hostname = url.hostname;
    const mainParts = hostname.split('.').slice(-2).join('.');
    return {
      mainParts,
      hostname: hostname,
      isInStation: IN_STATION_LINK.includes(hostname),
      url: maybeUrl
    }
  } catch (e) {
    return null
  }
}