summaryrefslogtreecommitdiff
path: root/node_modules/locutus/php/filesystem/realpath.js.map
blob: 4e5046e1117acd46fd3e703e139532b37da49822 (plain) (blame)
1
{"version":3,"sources":["../../../src/php/filesystem/realpath.js"],"names":["module","exports","realpath","path","window","nodePath","require","normalize","p","arr","r","location","href","replace","indexOf","substring","lastIndexOf","split","k","length","pop","push","join"],"mappings":";;AAAAA,OAAOC,OAAP,GAAiB,SAASC,QAAT,CAAmBC,IAAnB,EAAyB;AACxC;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAI,OAAOC,MAAP,KAAkB,WAAtB,EAAmC;AACjC,QAAIC,WAAWC,QAAQ,MAAR,CAAf;AACA,WAAOD,SAASE,SAAT,CAAmBJ,IAAnB,CAAP;AACD;;AAED,MAAIK,IAAI,CAAR;AACA,MAAIC,MAAM,EAAV,CAdwC,CAc3B;AACb,MAAIC,IAAI,KAAKN,MAAL,CAAYO,QAAZ,CAAqBC,IAA7B,CAfwC,CAeN;;AAElC;AACAT,SAAO,CAACA,OAAO,EAAR,EAAYU,OAAZ,CAAoB,IAApB,EAA0B,GAA1B,CAAP;AACA,MAAIV,KAAKW,OAAL,CAAa,KAAb,MAAwB,CAAC,CAA7B,EAAgC;AAC9BN,QAAI,CAAJ;AACD;;AAED;AACA,MAAI,CAACA,CAAL,EAAQ;AACNL,WAAOO,EAAEK,SAAF,CAAY,CAAZ,EAAeL,EAAEM,WAAF,CAAc,GAAd,IAAqB,CAApC,IAAyCb,IAAhD;AACD;;AAED;AACAM,QAAMN,KAAKc,KAAL,CAAW,GAAX,CAAN,CA7BwC,CA6BlB;AACtBd,SAAO,EAAP,CA9BwC,CA8B9B;AACV,OAAK,IAAIe,CAAT,IAAcT,GAAd,EAAmB;AAAE;AACnB,QAAIA,IAAIS,CAAJ,MAAW,GAAf,EAAoB;AAClB;AACD;AACD;AACA,QAAIT,IAAIS,CAAJ,MAAW,IAAf,EAAqB;AACnB;;AAEA,UAAIf,KAAKgB,MAAL,GAAc,CAAlB,EAAqB;AACnBhB,aAAKiB,GAAL;AACD;AACF,KAND,MAMO;AACL;AACA;AACA;AACA;AACA,UAAKjB,KAAKgB,MAAL,GAAc,CAAf,IAAsBV,IAAIS,CAAJ,MAAW,EAArC,EAA0C;AACxCf,aAAKkB,IAAL,CAAUZ,IAAIS,CAAJ,CAAV;AACD;AACF;AACF;;AAED;AACA,SAAOf,KAAKmB,IAAL,CAAU,GAAV,CAAP;AACD,CAvDD","file":"realpath.js","sourcesContent":["module.exports = function realpath (path) {\n  //  discuss at: http://locutus.io/php/realpath/\n  // original by: mk.keck\n  // improved by: Kevin van Zonneveld (http://kvz.io)\n  //      note 1: Returned path is an url like e.g. 'http://yourhost.tld/path/'\n  //   example 1: realpath('some/dir/.././_supporters/pj_test_supportfile_1.htm')\n  //   returns 1: 'some/_supporters/pj_test_supportfile_1.htm'\n\n  if (typeof window === 'undefined') {\n    var nodePath = require('path')\n    return nodePath.normalize(path)\n  }\n\n  var p = 0\n  var arr = [] // Save the root, if not given\n  var r = this.window.location.href // Avoid input failures\n\n  // Check if there's a port in path (like 'http://')\n  path = (path + '').replace('\\\\', '/')\n  if (path.indexOf('://') !== -1) {\n    p = 1\n  }\n\n  // Ok, there's not a port in path, so let's take the root\n  if (!p) {\n    path = r.substring(0, r.lastIndexOf('/') + 1) + path\n  }\n\n  // Explode the given path into it's parts\n  arr = path.split('/') // The path is an array now\n  path = [] // Foreach part make a check\n  for (var k in arr) { // This is'nt really interesting\n    if (arr[k] === '.') {\n      continue\n    }\n    // This reduces the realpath\n    if (arr[k] === '..') {\n      /* But only if there more than 3 parts in the path-array.\n       * The first three parts are for the uri */\n      if (path.length > 3) {\n        path.pop()\n      }\n    } else {\n      // This adds parts to the realpath\n      // But only if the part is not empty or the uri\n      // (the first three parts ar needed) was not\n      // saved\n      if ((path.length < 2) || (arr[k] !== '')) {\n        path.push(arr[k])\n      }\n    }\n  }\n\n  // Returns the absloute path as a string\n  return path.join('/')\n}\n"]}