{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["//https://github.com/staticallyio/statically/blob/main/src/pages/convert.js\n//TODO: convert gist link to raw data linknp\n\n/**\n * Convert URL to Statically.io URL\n * @param {string}  url - Input raw url\n * @return {(string|null)} Statically.io CDN url or null if url is not valid\n */\nfunction convert(url?: string) {\n  const DICTIONARY: Record<string, string> = {\n    \"https?:\\\\/\\\\/raw\\\\.github(?:usercontent)?\\\\.com\\\\/([^\\\\/]+)\\\\/([^\\\\/]+)\\\\/([^\\\\/]+)\\\\/([^?&#]+)\":\n      \"https://cdn.statically.io/gh/$1/$2/$3/$4\",\n    \"https?:\\\\/\\\\/gist\\\\.githubusercontent\\\\.com\\\\/(\\\\S+)\":\n      \"https://cdn.statically.io/gist/$1\",\n    \"https?:\\\\/\\\\/github\\\\.com\\\\/([^\\\\/]+)\\\\/([^\\\\/]+)\\\\/(?!releases\\\\/)(?:(?:blob|raw)\\\\/)?([^\\\\/]+)\\\\/([^?&#]+)\":\n      \"https://cdn.statically.io/gh/$1/$2/$3/$4\",\n    \"https?:\\\\/\\\\/gitlab\\\\.com\\\\/([^\\\\/].*)\\\\/-\\\\/(?:raw|blob)\\\\/(.+\\\\..+?)(?:\\\\?.*)?\":\n      \"https://cdn.statically.io/gl/$1/$2\",\n    \"https?:\\\\/\\\\/bitbucket\\\\.org\\\\/([^\\\\/]+\\\\/[^\\\\/]+)\\\\/(?:raw|src)\\\\/(.+\\\\..+?)(?:\\\\?.*)?\":\n      \"https://cdn.statically.io/bb/$1/$2\",\n  };\n\n  if (!url) {\n    return null;\n  }\n\n  for (let key in DICTIONARY) {\n    const regex = new RegExp(\"^\" + key + \"$\");\n    const match = url.match(regex);\n    const output = DICTIONARY[key];\n    if (match) {\n      return url.replace(regex, output);\n    }\n  }\n\n  return null;\n}\n\nexport default convert;\n"],"names":["url","DICTIONARY","key","regex","RegExp","match","replace"],"mappings":"eAQA,SAAiBA,GACf,IAAMC,EAAqC,CACzC,kGACE,2CACF,uDACE,oCACF,+GACE,2CACF,mFACE,qCACF,0FACE,sCAGJ,IAAKD,EACH,YAGF,IAAK,IAAIE,KAAOD,EAAY,CAC1B,IAAME,EAAQ,IAAIC,OAAO,IAAMF,EAAM,KAGrC,GAFcF,EAAIK,MAAMF,GAGtB,OAAOH,EAAIM,QAAQH,EAFNF,EAAWC,IAM5B"}