diff --git a/client/invoke.js b/client/invoke.js index 92aac978..5c60b046 100644 --- a/client/invoke.js +++ b/client/invoke.js @@ -25,7 +25,7 @@ export default function invoke(name, hash) { } if (/get[A-Z]([*]*)/.test(name)) { options.method = 'GET'; - url += `?payload=${body}`; + url += `?payload=${encodeURIComponent(body)}`; } else { options.body = body; if (/patch[A-Z]([*]*)/.test(name)) { diff --git a/tests/src/ServerFunctions.njs b/tests/src/ServerFunctions.njs index e3559d1f..68a3e900 100644 --- a/tests/src/ServerFunctions.njs +++ b/tests/src/ServerFunctions.njs @@ -3,6 +3,8 @@ import { readFileSync } from 'fs'; import Nullstack from 'nullstack'; import { clientOnly, serverOnly } from './helpers'; +const decodedString = "! * ' ( ) ; : @ & = + $ , / ? % # [ ]" + class ServerFunctions extends Nullstack { count = 0; @@ -53,6 +55,10 @@ class ServerFunctions extends Nullstack { return number * 2 + 1 } + static async getEncodedString({ string }) { + return string === decodedString + } + async initiate() { this.statement = await this.useNodeFileSystem(); this.response = await this.useFetchInNode(); @@ -62,6 +68,7 @@ class ServerFunctions extends Nullstack { async hydrate() { this.clientOnly = clientOnly(); this.doublePlusOneClient = await ServerFunctions.getDoublePlusOne({ number: 34 }) + this.acceptsSpecialCharacters = await this.getEncodedString({ string: decodedString }) } render() { @@ -77,6 +84,7 @@ class ServerFunctions extends Nullstack {
+ ) } diff --git a/tests/src/ServerFunctions.test.js b/tests/src/ServerFunctions.test.js index d0eb6c84..2c17657c 100644 --- a/tests/src/ServerFunctions.test.js +++ b/tests/src/ServerFunctions.test.js @@ -54,4 +54,10 @@ describe('ServerFunctions', () => { expect(element).toBeTruthy(); }); + test('get server functions can accept special characters', async () => { + await page.waitForSelector('[data-accepts-special-characters]'); + const element = await page.$('[data-accepts-special-characters]'); + expect(element).toBeTruthy(); + }); + }); \ No newline at end of file