.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / resolve-url / readme.md
1 Overview\r
2 ========\r
3 \r
4 [![browser support](https://ci.testling.com/lydell/resolve-url.png)](https://ci.testling.com/lydell/resolve-url)\r
5 \r
6 Like Node.js’ [`path.resolve`]/[`url.resolve`] for the browser.\r
7 \r
8 ```js\r
9 var resolveUrl = require("resolve-url")\r
10 \r
11 window.location\r
12 // https://example.com/articles/resolving-urls/edit\r
13 \r
14 resolveUrl("remove")\r
15 // https://example.com/articles/resolving-urls/remove\r
16 \r
17 resolveUrl("/static/scripts/app.js")\r
18 // https://example.com/static/scripts/app.js\r
19 \r
20 // Imagine /static/scripts/app.js contains `//# sourceMappingURL=../source-maps/app.js.map`\r
21 resolveUrl("/static/scripts/app.js", "../source-maps/app.js.map")\r
22 // https://example.com/static/source-maps/app.js.map\r
23 \r
24 resolveUrl("/static/scripts/app.js", "../source-maps/app.js.map", "../coffee/app.coffee")\r
25 // https://example.com/static/coffee/app.coffee\r
26 \r
27 resolveUrl("//cdn.example.com/jquery.js")\r
28 // https://cdn.example.com/jquery.js\r
29 \r
30 resolveUrl("http://foo.org/")\r
31 // http://foo.org/\r
32 ```\r
33 \r
34 \r
35 Installation\r
36 ============\r
37 \r
38 - `npm install resolve-url`\r
39 - `bower install resolve-url`\r
40 - `component install lydell/resolve-url`\r
41 \r
42 Works with CommonJS, AMD and browser globals, through UMD.\r
43 \r
44 \r
45 Usage\r
46 =====\r
47 \r
48 ### `resolveUrl(...urls)` ###\r
49 \r
50 Pass one or more urls. Resolves the last one to an absolute url, using the\r
51 previous ones and `window.location`.\r
52 \r
53 It’s like starting out on `window.location`, and then clicking links with the\r
54 urls as `href` attributes in order, from left to right.\r
55 \r
56 Unlike Node.js’ [`path.resolve`], this function always goes through all of the\r
57 arguments, from left to right. `path.resolve` goes from right to left and only\r
58 in the worst case goes through them all. Should that matter.\r
59 \r
60 Actually, the function is _really_ like clicking a lot of links in series: An\r
61 actual `<a>` gets its `href` attribute set for each url! This means that the\r
62 url resolution of the browser is used, which makes this module really\r
63 light-weight.\r
64 \r
65 Also note that this functions deals with urls, not paths, so in that respect it\r
66 has more in common with Node.js’ [`url.resolve`]. But the arguments are more\r
67 like [`path.resolve`].\r
68 \r
69 [`path.resolve`]: http://nodejs.org/api/path.html#path_path_resolve_from_to\r
70 [`url.resolve`]: http://nodejs.org/api/url.html#url_url_resolve_from_to\r
71 \r
72 \r
73 Tests\r
74 =====\r
75 \r
76 Run `npm test`, which lints the code and then gives you a link to open in a\r
77 browser of choice (using `testling`).\r
78 \r
79 \r
80 License\r
81 =======\r
82 \r
83 [The X11 (“MIT”) License](LICENSE).\r