@jswork/next-redirect2url
v1.0.0
Published
Redirect url encode/decode.
Downloads
2
Readme
next-redirect2url
Redirect url encode/decode.
installation
npm install -S @jswork/next-redirect2url
apis
| api | params | description | | ------ | ------ | ------------- | | encode | - | desc balabala | | decode | - | desc balabala |
options - encode
| name | default | description | | ------ | ------------------ | -------------------------------- | | query | 'rediect' | The query key string | | encode | encodeURIComponent | The default value encode method. | | source | - | The url. | | target | - | The redirect url. |
options - decode
| name | default | description | | ------ | ------------------ | -------------------------------- | | query | 'rediect' | The query key string | | decode | decodeURIComponent | The default value decode method. | | url | - | The target url. |
usage
import NxRedirect2url from '@feizheng/next-redirect2url';
const str = NxRedirect2url.encode({
source: 'http://192.168.50.181/login',
target: 'https://www.mipengine.org?q1=1&q2=2',
});
// 'http://192.168.50.181/login?redirect=https%3A%2F%2Fwww.mipengine.org%3Fq1%3D1%26q2%3D2'
const res = NxRedirect2url.decode({
url: 'http://192.168.50.181/login?redirect=https%3A%2F%2Fwww.mipengine.org%3Fq1%3D1%26q2%3D2',
});
/*
{
target: 'https://www.mipengine.org?q1=1&q2=2',
source: 'http://192.168.50.181/login'
}
*/
license
Code released under the MIT license.