| 32 | |
| 33 | // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent |
| 34 | export function encodeRFC5987ValueChars(str: string) { |
| 35 | return ( |
| 36 | encodeURIComponent(str) |
| 37 | // Note that although RFC3986 reserves "!", RFC5987 does not, |
| 38 | // so we do not need to escape it |
| 39 | .replace(/['()]/g, escape) // i.e., %27 %28 %29 |
| 40 | .replace(/\*/g, '%2A') |
| 41 | // The following are not required for percent-encoding per RFC5987, |
| 42 | // so we can allow for a little better readability over the wire: |`^ |
| 43 | .replace(/%(?:7C|60|5E)/g, unescape) |
| 44 | ); |
| 45 | } |
| 46 | |
| 47 | async function forkContextWithScope(ctx: CordisContext) { |
| 48 | const scope = ctx.plugin(() => { }); |