{"name":"relative-url","description":"convert a partial url into an absolute url from your current location.","version":"1.0.1","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":"4a1ad8e422bec6e3ebcacdefb665b1e9534a1d35","bugs":{"url":"https://github.com/dominictarr/relative-url/issues"},"_id":"relative-url@1.0.1","_shasum":"aacd618d6e149f9f327c34a6d2c7f3a1726e6bd9","_from":".","_npmVersion":"3.8.6","_nodeVersion":"5.11.1","_npmUser":{"name":"dominictarr","email":"dominic.tarr@gmail.com"},"dist":{"shasum":"aacd618d6e149f9f327c34a6d2c7f3a1726e6bd9","tarball":"http://registry-npm.ywwl.com/relative-url/download/relative-url-1.0.1.tgz","integrity":"sha512-Y1JqqHx3twPyaHEjwScKwLSFFyioX/dBN3zhIKw7IB98uPrEU5GnQ/c/lRto5gGQhMwv0sAY2ueTvxbXWuaR7w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCp6dPKULlub41zNLm1NNnSw2P5ZAOuLF70oRd65cA1rAIhAI3Q7oOCgJtPvpyXrbayisMWZSnWuwOvd6i8CeiZ6Ztk"}],"size":3303,"noattachment":false,"key":"/relative-url/-/relative-url-1.0.1.tgz"},"maintainers":[{"name":"dominictarr","email":"dominic.tarr@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/relative-url-1.0.1.tgz_1464820872553_0.9257475782651454"},"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":1464820873023,"_cnpm_publish_time":1464820873023,"dist-tags":{"latest":"1.0.2"}}