Initial commit

This commit is contained in:
Developer
2025-04-21 16:03:20 +02:00
commit 2832896157
22874 changed files with 3092801 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2015 Unshift.io, Arnout Kazemier, the Contributors.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,51 @@
# origin(al)
[![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)
Original generates the origin URL for a given URL or URL object. In addition to
that it also comes with a simple `same` function to check if two URL's have the
same origin.
## Install
This module is browserify and node compatible and is therefor release in the npm
registry and can be installed using:
```
npm install --save original
```
## Usage
In all the examples we assume that the module is loaded using:
```js
'use strict';
var origin = require('original');
```
To get the origin of a given URL simply call `origin` function with any given
URL to get origin.
```js
var o = origin('https://google.com/foo/bar?path');
// o = https://google.com
```
To compare if two URL's share the same origin you can call the `same` method.
```js
if (origin.same('https://google.com/foo', 'https://primus.io')) {
console.log('same');
} else {
console.log('guess what, google.com and primus.io are not the same origin');
}
```
And that's it.
## License
MIT

View File

@@ -0,0 +1,46 @@
'use strict';
var parse = require('url-parse');
/**
* Transform an URL to a valid origin value.
*
* @param {String|Object} url URL to transform to it's origin.
* @returns {String} The origin.
* @api public
*/
function origin(url) {
if ('string' === typeof url) url = parse(url);
//
// 6.2. ASCII Serialization of an Origin
// http://tools.ietf.org/html/rfc6454#section-6.2
//
if (!url.protocol || !url.hostname) return 'null';
//
// 4. Origin of a URI
// http://tools.ietf.org/html/rfc6454#section-4
//
// States that url.scheme, host should be converted to lower case. This also
// makes it easier to match origins as everything is just lower case.
//
return (url.protocol +'//'+ url.host).toLowerCase();
}
/**
* Check if the origins are the same.
*
* @param {String} a URL or origin of a.
* @param {String} b URL or origin of b.
* @returns {Boolean}
* @api public
*/
origin.same = function same(a, b) {
return origin(a) === origin(b);
};
//
// Expose the origin
//
module.exports = origin;

View File

@@ -0,0 +1,64 @@
{
"_from": "original@>=0.0.5",
"_id": "original@1.0.2",
"_inBundle": false,
"_integrity": "sha512-hyBVl6iqqUOJ8FqRe+l/gS8H+kKYjrEndd5Pm1MfBtsEKA038HkkdbAl/72EAXGyonD/PFsvmVG+EvcIpliMBg==",
"_location": "/original",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "original@>=0.0.5",
"name": "original",
"escapedName": "original",
"rawSpec": ">=0.0.5",
"saveSpec": null,
"fetchSpec": ">=0.0.5"
},
"_requiredBy": [
"/eventsource"
],
"_resolved": "https://registry.npmjs.org/original/-/original-1.0.2.tgz",
"_shasum": "e442a61cffe1c5fd20a65f3261c26663b303f25f",
"_spec": "original@>=0.0.5",
"_where": "D:\\developments\\teaser-inertia\\nova-components\\NovaLeader\\node_modules\\eventsource",
"author": {
"name": "Arnout Kazemier"
},
"bugs": {
"url": "https://github.com/unshiftio/original/issues"
},
"bundleDependencies": false,
"dependencies": {
"url-parse": "^1.4.3"
},
"deprecated": false,
"description": "Generate the origin from an URL or check if two URL/Origins are the same",
"devDependencies": {
"assume": "~2.1.0",
"istanbul": "0.4.x",
"mocha": "~3.5.0",
"pre-commit": "~1.2.0"
},
"homepage": "https://github.com/unshiftio/original#readme",
"keywords": [
"origin",
"url",
"parse"
],
"license": "MIT",
"main": "index.js",
"name": "original",
"repository": {
"type": "git",
"url": "git+https://github.com/unshiftio/original.git"
},
"scripts": {
"100%": "istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100",
"coverage": "istanbul cover _mocha -- test.js",
"test": "mocha test.js",
"test-travis": "istanbul cover _mocha --report lcovonly -- test.js",
"watch": "mocha --watch test.js"
},
"version": "1.0.2"
}