{"name":"relative-url","description":"convert a partial url into an absolute url from your current location.","version":"1.0.2","homepage":"https://github.com/dominictarr/relative-url","repository":{"type":"git","url":"git://github.com/dominictarr/relative-url.git"},"dependencies":{},"devDependencies":{"tape":"^4.5.1"},"scripts":{"test":"set -e; for t in test/*.js; do node $t; done"},"author":{"name":"'Dominic Tarr'","email":"dominic.tarr@gmail.com","url":"dominictarr.com"},"license":"MIT","gitHead":"1650c32adfd987a4edba68eb3748b55a83695981","bugs":{"url":"https://github.com/dominictarr/relative-url/issues"},"_id":"relative-url@1.0.2","_shasum":"d21c52a72d6061018bcee9f9c9fc106bf7d65287","_from":".","_npmVersion":"3.8.6","_nodeVersion":"5.11.1","_npmUser":{"name":"dominictarr","email":"dominic.tarr@gmail.com"},"dist":{"shasum":"d21c52a72d6061018bcee9f9c9fc106bf7d65287","tarball":"http://registry-npm.ywwl.com/relative-url/download/relative-url-1.0.2.tgz","integrity":"sha512-jI1AmBVFFMXwQ3I6tIYVmVOjy8f+ogHbqkeb8/LL9tszEQiTV8I0l8XT4oEomUOoxfm698f92gYlNKeA/9LJVQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAOReK9Pipk6+UAdrSZxqpr0WIie8fMZJ8K6tPILcZeFAiEA+56utJzeFSET8aE7TDdRxGns7FT+1wQ3dTvnAVf30Z0="}],"size":3332,"noattachment":false,"key":"/relative-url/-/relative-url-1.0.2.tgz"},"maintainers":[{"name":"dominictarr","email":"dominic.tarr@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/relative-url-1.0.2.tgz_1465427322998_0.9249375476501882"},"directories":{},"readme":"# relative-url\n\nconvert a partial url into an absolute url from your current\nlocation.\n\nIn the WebSocket api, it expects a fully qualified url,\nbut this is awkward because we want to develop on localhost,\nand then deploy to a server with a proper domain,\nwith a different port.\n\nWe want to create a WebSocket at a path, and get whatever domain\nwe are on.\n\nThis module generalized [wsurl](https://www.npmjs.com/package/wsurl)\n\n## api: rurl(url, location, protocolMap, defaultProtocol)\n\n`url` is your partial url, it will be described below.\n`location` should be your is `window.location` or the output\nof `require('url').parse(absoluteUrl)`\n\nif you want to change the protocol, protocol map is a object\nmapping current to desired protocol.\n\nfor websockets, you'll probably want: `{http: 'ws', https: 'wss'}`\n\n`defaultProtocol` is what to set the protocol to otherwise.\nfor example, `'ws'` if `defaultProtocol` is not provided\nthe output protocol will the the same as `location.protocol`\n\n## examples\n\nfor the following location:\n``` js\nvar location = {\n  protocol: 'http',\n  host: 'server.com',\n  pathname '/foo'\n} //OR get this from window.location\n\nvar protocolMap = {http: 'ws', https: 'wss'}\n\nvar defaultProtocol : 'ws'\n\nvar rurl = require('relative-url')\nfunction relative (url) {\n  return rurl(url, location, protocolMap, defaultProtocol) \n}\n\n\n```\nand the above mentioned settings (suitable for websockets)\noutput will be as following.\n``` js\n\nrelative('/')            // => ws://server.com/\nrelative('/bar')         // => ws://server.com/bar\nrelative('//client.com') // => ws://client.com/\nrelative('//:9999')      // => ws://server.com:9999/\nrelative('?q=search'     // => ws://server.com/foo?q=search\n```\n\nnote that // denotes the start of the host.\nif you want to set the port without changing the domain,\nyou must still use // otherwise the url module will\nthink it's a path. I considered detecting that,\nbut then i saw [this comment](https://github.com/nodejs/node/blob/master/lib/url.js#L207-L220)\nand got scared of learning too much about urls.\n\n## License\n\nMIT\n\n\n\n\n\n\n\n\n\n\n\n\n\n","publish_time":1465427323512,"_cnpm_publish_time":1465427323512,"dist-tags":{"latest":"1.0.2"}}