Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/forthedamn/safe-window-location
location parent(top) window safely in koa
https://github.com/forthedamn/safe-window-location
koa safe safe-location window xss
Last synced: about 1 month ago
JSON representation
location parent(top) window safely in koa
- Host: GitHub
- URL: https://github.com/forthedamn/safe-window-location
- Owner: forthedamn
- License: mit
- Created: 2017-12-25T06:30:36.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-06-27T06:07:23.000Z (over 6 years ago)
- Last Synced: 2024-11-08T17:05:48.633Z (about 1 month ago)
- Topics: koa, safe, safe-location, window, xss
- Language: JavaScript
- Homepage:
- Size: 94.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# safe-window-location
[![NPM version][npm-image]][npm-url]
[![build status](https://img.shields.io/travis/forthedamn/safe-window-location.svg)](https://travis-ci.org/forthedamn/safe-window-location)
[![code coverage](https://img.shields.io/codecov/c/github/forthedamn/safe-window-location.svg)](https://codecov.io/gh/forthedamn/safe-window-location)
[![license](https://img.shields.io/github/license/forthedamn/safe-window-location.svg)](LICENSE)[npm-image]: https://img.shields.io/npm/v/safe-window-location.svg?style=flat-square
[npm-url]: https://npmjs.org/package/safe-window-location> redirect parent(top) window location safely
## Install
```sh
npm install safe-window-locationyarn add safe-window-location
```## Usage
```
// ./config/default.jsmodule.exports = {
urlWhiteList: [
/**
* allow the hostname end with 'github.com'
* like 'https://github.com/**'
*/
/github\.com$/
]
}
``````js
const SafeWindowLocation = require('safe-window-location');const app = new Koa();
app.use((ctx, next) => {
// set parent window as new location
return SafeWindowLocation(ctx, 'new location', 'parent', 'urlWhiteList');
})
```param | usage | required | default
--- | --- | ---| ---
ctx | koa context | yes |
location | window location, like https://www.npmjs.com | - | /
target | window target, like window.parent | - | parent
config name | config option name | - | whiteList