diff --git a/.ipynb_checkpoints/Untitled-checkpoint.ipynb b/.ipynb_checkpoints/Untitled-checkpoint.ipynb new file mode 100644 index 0000000..4c7347e --- /dev/null +++ b/.ipynb_checkpoints/Untitled-checkpoint.ipynb @@ -0,0 +1,48 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "d5741a3b-45f6-457c-8b2c-9425b0177023", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "1+1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f0564c86-d8c1-4f96-a69d-8eec50ccd9ff", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "jp-Babel (Node.js)", + "language": "babel", + "name": "babel" + }, + "language_info": { + "file_extension": ".js", + "mimetype": "application/javascript", + "name": "javascript", + "version": "17.9.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/.ipynb_checkpoints/qs-checkpoint.ipynb b/.ipynb_checkpoints/qs-checkpoint.ipynb new file mode 100644 index 0000000..e2bb1ac --- /dev/null +++ b/.ipynb_checkpoints/qs-checkpoint.ipynb @@ -0,0 +1,198 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "e28a05ae-c5c5-4dc5-88b4-9090492f13e2", + "metadata": {}, + "source": [ + "# qs\n", + "- A querystring parsing and stringifying library with some added security.\n", + "- [https://www.npmjs.com/package/qs](https://www.npmjs.com/package/qs)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "a1d79a6e-3479-41cc-bc94-bd4d5b55e788", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{ a: 'b', c: 'd' }" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import qs from \"qs\"\n", + "qs.parse('?a=b&c=d', { ignoreQueryPrefix: true })" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "b6a27923-d70c-4403-b977-9d3901a9c204", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "/admin/reginfo?id=123®Id=456&category=789\n" + ] + }, + { + "data": { + "text/plain": [ + "undefined" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import qs from \"qs\"\n", + "const item = {id:123,regId:456,category:789}\n", + "const url = `/admin/reginfo?${qs.stringify(item)}`\n", + "console.log(url)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "0425adb4-a182-47a5-8fc2-8df4815069eb", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{ a: 'b' }" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import qs from \"qs\"\n", + "qs.parse('a=b&c=d', { parameterLimit: 1 });" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "f7f2490d-52b3-41c8-a19f-d6be53095d09", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{ a: 'b', c: 'd' }" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import qs from \"qs\"\n", + "qs.parse('?a=b&c=d', { ignoreQueryPrefix: true })" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "a317f8a9-6944-47f5-99b8-9cabac49608e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{ a: 'b', c: 'd' }" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import qs from \"qs\"\n", + "qs.parse('a=b;c=d', { delimiter: ';' })" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "da3327c1-6146-43f5-9301-dd066170ec53", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{ a: 'b', c: 'd', e: 'f' }" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import qs from \"qs\"\n", + "qs.parse('a=b;c=d,e=f', { delimiter: /[;,]/ })" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "c32e7427-7d1a-4f0d-a84f-b20403290883", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "undefined" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "var qs = require('qs');\n", + "var assert = require('assert');\n", + "\n", + "var obj = qs.parse('a=c');\n", + "assert.deepEqual(obj, { a: 'c' });\n", + "\n", + "var str = qs.stringify(obj);\n", + "assert.equal(str, 'a=c');\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "jp-Babel (Node.js)", + "language": "babel", + "name": "babel" + }, + "language_info": { + "file_extension": ".js", + "mimetype": "application/javascript", + "name": "javascript", + "version": "17.9.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Untitled.ipynb b/Untitled.ipynb new file mode 100644 index 0000000..4c7347e --- /dev/null +++ b/Untitled.ipynb @@ -0,0 +1,48 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "d5741a3b-45f6-457c-8b2c-9425b0177023", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "1+1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f0564c86-d8c1-4f96-a69d-8eec50ccd9ff", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "jp-Babel (Node.js)", + "language": "babel", + "name": "babel" + }, + "language_info": { + "file_extension": ".js", + "mimetype": "application/javascript", + "name": "javascript", + "version": "17.9.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/qs.ipynb b/qs.ipynb new file mode 100644 index 0000000..e2bb1ac --- /dev/null +++ b/qs.ipynb @@ -0,0 +1,198 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "e28a05ae-c5c5-4dc5-88b4-9090492f13e2", + "metadata": {}, + "source": [ + "# qs\n", + "- A querystring parsing and stringifying library with some added security.\n", + "- [https://www.npmjs.com/package/qs](https://www.npmjs.com/package/qs)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "a1d79a6e-3479-41cc-bc94-bd4d5b55e788", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{ a: 'b', c: 'd' }" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import qs from \"qs\"\n", + "qs.parse('?a=b&c=d', { ignoreQueryPrefix: true })" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "b6a27923-d70c-4403-b977-9d3901a9c204", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "/admin/reginfo?id=123®Id=456&category=789\n" + ] + }, + { + "data": { + "text/plain": [ + "undefined" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import qs from \"qs\"\n", + "const item = {id:123,regId:456,category:789}\n", + "const url = `/admin/reginfo?${qs.stringify(item)}`\n", + "console.log(url)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "0425adb4-a182-47a5-8fc2-8df4815069eb", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{ a: 'b' }" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import qs from \"qs\"\n", + "qs.parse('a=b&c=d', { parameterLimit: 1 });" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "f7f2490d-52b3-41c8-a19f-d6be53095d09", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{ a: 'b', c: 'd' }" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import qs from \"qs\"\n", + "qs.parse('?a=b&c=d', { ignoreQueryPrefix: true })" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "a317f8a9-6944-47f5-99b8-9cabac49608e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{ a: 'b', c: 'd' }" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import qs from \"qs\"\n", + "qs.parse('a=b;c=d', { delimiter: ';' })" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "da3327c1-6146-43f5-9301-dd066170ec53", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{ a: 'b', c: 'd', e: 'f' }" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import qs from \"qs\"\n", + "qs.parse('a=b;c=d,e=f', { delimiter: /[;,]/ })" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "c32e7427-7d1a-4f0d-a84f-b20403290883", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "undefined" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "var qs = require('qs');\n", + "var assert = require('assert');\n", + "\n", + "var obj = qs.parse('a=c');\n", + "assert.deepEqual(obj, { a: 'c' });\n", + "\n", + "var str = qs.stringify(obj);\n", + "assert.equal(str, 'a=c');\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "jp-Babel (Node.js)", + "language": "babel", + "name": "babel" + }, + "language_info": { + "file_extension": ".js", + "mimetype": "application/javascript", + "name": "javascript", + "version": "17.9.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}