1.0.4 • Published 7 years ago
safe-window-location v1.0.4
safe-window-location
redirect parent(top) window location safely
Install
npm install safe-window-location
yarn add safe-window-locationUsage
// ./config/default.js
module.exports = {
urlWhiteList: [
/**
* allow the hostname end with 'github.com'
* like 'https://github.com/**'
*/
/github\.com$/
]
}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 |