source: trip-planner-front/node_modules/original/README.md@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.7 KB
Line 
1# origin(al)
2
3[![Made by unshift](https://img.shields.io/badge/made%20by-unshift-00ffcc.svg?style=flat-square)](http://unshift.io)[![Version npm](http://img.shields.io/npm/v/original.svg?style=flat-square)](http://browsenpm.org/package/original)[![Build Status](http://img.shields.io/travis/unshiftio/original/master.svg?style=flat-square)](https://travis-ci.org/unshiftio/original)[![Dependencies](https://img.shields.io/david/unshiftio/original.svg?style=flat-square)](https://david-dm.org/unshiftio/original)[![Coverage Status](http://img.shields.io/coveralls/unshiftio/original/master.svg?style=flat-square)](https://coveralls.io/r/unshiftio/original?branch=master)[![IRC channel](http://img.shields.io/badge/IRC-irc.freenode.net%23unshift-00a8ff.svg?style=flat-square)](http://webchat.freenode.net/?channels=unshift)
4
5Original generates the origin URL for a given URL or URL object. In addition to
6that it also comes with a simple `same` function to check if two URL's have the
7same origin.
8
9## Install
10
11This module is browserify and node compatible and is therefor release in the npm
12registry and can be installed using:
13
14```
15npm install --save original
16```
17
18## Usage
19
20In all the examples we assume that the module is loaded using:
21
22```js
23'use strict';
24
25var origin = require('original');
26```
27
28To get the origin of a given URL simply call `origin` function with any given
29URL to get origin.
30
31```js
32var o = origin('https://google.com/foo/bar?path');
33
34// o = https://google.com
35```
36
37To compare if two URL's share the same origin you can call the `same` method.
38
39```js
40if (origin.same('https://google.com/foo', 'https://primus.io')) {
41 console.log('same');
42} else {
43 console.log('guess what, google.com and primus.io are not the same origin');
44}
45```
46
47And that's it.
48
49## License
50
51MIT
Note: See TracBrowser for help on using the repository browser.