diff --git a/example-ws/package.json b/example-ws/package.json index 00a7d00..3a2f829 100644 --- a/example-ws/package.json +++ b/example-ws/package.json @@ -23,6 +23,7 @@ "typescript": "^3.8.3" }, "dependencies": { - "ws": "^7.2.3" + "ws": "^7.2.3", + "@braintree/sanitize-url": "5.0.0" } } diff --git a/example-ws/src/index.ts b/example-ws/src/index.ts index c0ad574..4bb2da7 100644 --- a/example-ws/src/index.ts +++ b/example-ws/src/index.ts @@ -3,6 +3,7 @@ import * as fs from "fs"; import * as WebSocket from "ws"; import { IRpc } from "./rpc/rpc-common"; import { RpcExtensionWebSockets } from "./rpc/rpc-extension-ws"; +import { sanitizeUrl } from '@braintree/sanitize-url'; // web socket server const wss = new WebSocket.Server({ port: 8081 }, () => { @@ -29,8 +30,8 @@ wss.on("connection", function connection(ws) { // static content http server http.createServer(function (req, res) { - const url = req.url; - fs.readFile(`${__dirname}/static${req.url}`, function (err,data) { + const url = sanitizeUrl(req.url); + fs.readFile(`${__dirname}/static${url}`, function (err,data) { if (err) { res.writeHead(404); res.end(JSON.stringify(err)); diff --git a/example/src/extension.ts b/example/src/extension.ts index 3c105a8..25ca89d 100644 --- a/example/src/extension.ts +++ b/example/src/extension.ts @@ -4,7 +4,6 @@ import * as path from 'path'; import * as vscode from 'vscode'; import * as fs from 'fs'; import { RpcExtension } from '@sap-devx/webview-rpc/out.ext/rpc-extension'; -import { SSL_OP_CIPHER_SERVER_PREFERENCE } from 'constants'; // this method is called when your extension is activated // your extension is activated the very first time the command is executed