summaryrefslogtreecommitdiff
path: root/node_modules/locutus/php/net-gopher/gopher_parsedir.js.map
blob: cd57753596bc464c8301e42e9317788670448bd4 (plain) (blame)
1
{"version":3,"sources":["../../../src/php/net-gopher/gopher_parsedir.js"],"names":["module","exports","gopher_parsedir","dirent","entryPattern","entry","match","Error","type","data","title","path","host","port"],"mappings":";;AAAAA,OAAOC,OAAP,GAAiB,SAASC,eAAT,CAA0BC,MAA1B,EAAkC;AAAE;AACnD;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;;;;;AAiBA,MAAIC,eAAe,6CAAnB;AACA,MAAIC,QAAQF,OAAOG,KAAP,CAAaF,YAAb,CAAZ;;AAEA,MAAIC,UAAU,IAAd,EAAoB;AAClB,UAAM,IAAIE,KAAJ,CAAU,qCAAV,CAAN;AACA;AACD;;AAED,MAAIC,OAAOH,MAAM,CAAN,CAAX;AACA,UAAQG,IAAR;AACE,SAAK,GAAL;AACA;AACEA,aAAO,GAAP;AACA;AACF,SAAK,GAAL;AACA;AACEA,aAAO,CAAP;AACA;AACF,SAAK,GAAL;AACA;AACEA,aAAO,CAAP;AACA;AACF,SAAK,GAAL;AACA;AACEA,aAAO,CAAP;AACA;AACF,SAAK,GAAL;AACA;AACEA,aAAO,CAAP;AACA;AACF,SAAK,GAAL;AACA;AACEA,aAAO,CAAP;AACA;AACF,SAAK,GAAL;AACA;AACEA,aAAO,CAAP;AACA;AACF,SAAK,GAAL;AACA;AACEA,aAAO,GAAP;AACA;AACF;AACE,aAAO;AACLA,cAAM,CAAC,CADF;AAELC,cAAMN;AAFD,OAAP,CAlCJ,CAqCM;AArCN;AAuCA,SAAO;AACLK,UAAMA,IADD;AAELE,WAAOL,MAAM,CAAN,CAFF;AAGLM,UAAMN,MAAM,CAAN,CAHD;AAILO,UAAMP,MAAM,CAAN,CAJD;AAKLQ,UAAMR,MAAM,CAAN;AALD,GAAP;AAOD,CA/ED","file":"gopher_parsedir.js","sourcesContent":["module.exports = function gopher_parsedir (dirent) { // eslint-disable-line camelcase\n  //  discuss at: http://locutus.io/php/gopher_parsedir/\n  // original by: Brett Zamir (http://brett-zamir.me)\n  //   example 1: var entry = gopher_parsedir('0All about my gopher site.\\t/allabout.txt\\tgopher.example.com\\t70\\u000d\\u000a')\n  //   example 1: entry.title\n  //   returns 1: 'All about my gopher site.'\n\n  /* Types\n   * 0 = plain text file\n   * 1 = directory menu listing\n   * 2 = CSO search query\n   * 3 = error message\n   * 4 = BinHex encoded text file\n   * 5 = binary archive file\n   * 6 = UUEncoded text file\n   * 7 = search engine query\n   * 8 = telnet session pointer\n   * 9 = binary file\n   * g = Graphics file format, primarily a GIF file\n   * h = HTML file\n   * i = informational message\n   * s = Audio file format, primarily a WAV file\n   */\n\n  var entryPattern = /^(.)(.*?)\\t(.*?)\\t(.*?)\\t(.*?)\\u000d\\u000a$/\n  var entry = dirent.match(entryPattern)\n\n  if (entry === null) {\n    throw new Error('Could not parse the directory entry')\n    // return false;\n  }\n\n  var type = entry[1]\n  switch (type) {\n    case 'i':\n    // GOPHER_INFO\n      type = 255\n      break\n    case '1':\n    // GOPHER_DIRECTORY\n      type = 1\n      break\n    case '0':\n    // GOPHER_DOCUMENT\n      type = 0\n      break\n    case '4':\n    // GOPHER_BINHEX\n      type = 4\n      break\n    case '5':\n    // GOPHER_DOSBINARY\n      type = 5\n      break\n    case '6':\n    // GOPHER_UUENCODED\n      type = 6\n      break\n    case '9':\n    // GOPHER_BINARY\n      type = 9\n      break\n    case 'h':\n    // GOPHER_HTTP\n      type = 254\n      break\n    default:\n      return {\n        type: -1,\n        data: dirent\n      } // GOPHER_UNKNOWN\n  }\n  return {\n    type: type,\n    title: entry[2],\n    path: entry[3],\n    host: entry[4],\n    port: entry[5]\n  }\n}\n"]}