https://github.com/keqingrong/is-same-origin
Check if two URLs are same origin
https://github.com/keqingrong/is-same-origin
same-origin whatwg-url
Last synced: about 1 month ago
JSON representation
Check if two URLs are same origin
- Host: GitHub
- URL: https://github.com/keqingrong/is-same-origin
- Owner: keqingrong
- License: mit
- Created: 2018-03-22T15:23:32.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-03T06:12:59.000Z (almost 8 years ago)
- Last Synced: 2025-09-21T16:08:28.397Z (8 months ago)
- Topics: same-origin, whatwg-url
- Language: JavaScript
- Size: 13.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# is-same-origin
[](https://www.npmjs.com/package/is-same-origin)
> Check if two URLs are same origin, for Node and the browser
## Installation
```sh
npm install is-same-origin
```
```js
// Using ES6 modules
import isSameOrigin from 'is-same-origin';
// Using CommonJS modules
const isSameOrigin = require('is-same-origin');
```
The CDN build is also available on unpkg:
- [unpkg.com/is-same-origin/dist/index.min.js](https://unpkg.com/is-same-origin/dist/index.min.js)
- [unpkg.com/is-same-origin/dist/index-with-polyfill.min.js](https://unpkg.com/is-same-origin/dist/index-with-polyfill.min.js) - With a [URL API](https://caniuse.com/#feat=url) polyfill
## Usage
```js
const isSameOrigin = require('is-same-origin');
isSameOrigin('http://www.example.com/dir/page.html',
'http://www.example.com/dir/page2.html');
// => true
isSameOrigin('http://www.example.com/dir/page.html',
'http://en.example.com/dir/other.html');
// => false
```
## License
MIT