JSPM

location

0.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2440
  • Score
    100M100P100Q117165F

A Browser-esque location object

Package Exports

  • location

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (location) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

location

A mock location object for unit tests and such and to maintain compatibility between Ender.JS and Node.JS

For best results, create a location.config.js in the working directory of your app that returns a location object that should be used.

Current Implementation

var fs = require('fs')
  , location
  , defaultLocation
  ;

defaultLocation = {
  "origin": "http://localhost:3000",
  "pathname": "/",
  "host": "localhost:3000",
  "hostname": "localhost",
  "port": "3000",
  "search": "",
  "hash": "#home",
  "href": "http://localhost:3000/#home",
  "protocol": "http:"
};

try {
  // TODO try all from `__dirname` to `/` before giving up
  location = fs.readFileSync('./location.config.js');
} catch(e) {
  location = defaultLocation;
}

module.exports = location;

TODO

Look for __dirname + "location.config.js" and then look up one directory at each failure before finally giving up and using the default object.