autolevel.js

Automatically use the right abstract-leveldown module for your configuration
git clone git://git.finwo.net/lib/autolevel.js
Log | Files | Refs | README | LICENSE

to-absolute-path.js (517B)


      1 const basedir = global.approot || (''+require('app-root-path')),
      2       path    = require('path');
      3 
      4 module.exports = function toAbsolutePath( parsedLocation ) {
      5   if ( 'string' === typeof parsedLocation ) {
      6     parsedLocation = require('url-parse')(parsedLocation);
      7   }
      8   let targetLocation = '/' + parsedLocation.hostname + parsedLocation.pathname;
      9   if (!( parsedLocation.protocol && parsedLocation.hostname )) {
     10     targetLocation = basedir + targetLocation;
     11   }
     12   return targetLocation.replace(/\//g,path.sep);
     13 };