Skip to content

Commit c5a110d

Browse files
committed
Update dependencies
1 parent fa9045c commit c5a110d

File tree

3 files changed

+118
-226
lines changed

3 files changed

+118
-226
lines changed

index.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ const commandLineUsage = require("command-line-usage");
88
const express = require("express");
99
const qr = require("qr-image");
1010
const socketIo = require("socket.io");
11-
const uuid = require("uuid/v4");
11+
const { v4: uuidv4 } = require('uuid');
1212

1313
const states = {};
1414
const multiplexes = {};
1515

1616
const createImage = async (content) =>
1717
new Promise((resolve, reject) => {
18-
var chunks = [];
18+
const chunks = [];
1919

2020
const stream = qr.image(content);
2121
stream.on("data", (chunk) => chunks.push(chunk));
2222
stream.on("end", () => {
23-
var result = Buffer.concat(chunks);
23+
const result = Buffer.concat(chunks);
2424
resolve(result.toString("base64"));
2525
});
2626
stream.on("error", reject);
@@ -45,8 +45,8 @@ const initMaster = (socket, initialData, baseUrl, hashsecret) => {
4545
}
4646

4747
if (remoteId === null) {
48-
remoteId = uuid();
49-
multiplexId = uuid();
48+
remoteId = uuidv4();
49+
multiplexId = uuidv4();
5050
hash = mkHash(remoteId, multiplexId, hashsecret);
5151
}
5252

@@ -160,12 +160,12 @@ const index = async (res, path) => {
160160
fs.promises.readdir(path, { encoding: "utf-8" })
161161
.then(files => {
162162
const list = "<li>" +
163-
files.map(file => '<a href="' + encodeURI(file) + '/">' + file.replace(/[\u00A0-\u9999<>\&]/g, i => "&#" + i.charCodeAt(0) + ";") + "</a>")
163+
files.map(file => '<a href="' + encodeURI(file) + '/">' + file.replace(/[\u00A0-\u9999<>&"']/g, i => "&#" + i.charCodeAt(0) + ";") + "</a>")
164164
.join("</li><li>") +
165165
"</li>";
166166

167167
res.set("Content-Type", "text/html");
168-
res.send("<!DOCTYPE html><html><head><title>Directory Listing</title></head><ul>" + list + "</ul>");
168+
res.send("<!DOCTYPE html><html lang='en'><head><title>Directory Listing</title></head><ul>" + list + "</ul>");
169169
})
170170
.catch(e => {
171171
console.warn("Unable to build directory listing:", e);
@@ -239,7 +239,7 @@ const parseArgs = () => {
239239
name: "hashsecret",
240240
alias: "a",
241241
typeLabel: "{unterline string}",
242-
defaultValue: process.env.PRESENTATION_HASH_SECRET || uuid(),
242+
defaultValue: process.env.PRESENTATION_HASH_SECRET || uuidv4(),
243243
description: "A secret which is used to resume a session after the presentation is reloaded (default: a random value, env: PRESENTATION_PRESENTATION_PATH)"
244244
},
245245
{
@@ -297,7 +297,9 @@ createServer(args, app).then(server => {
297297
app.use(prefix, express.static(args.presentationpath));
298298
app.get(prefix, (_req, res) => index(res, args.presentationpath));
299299

300-
const io = socketIo.listen(server, { path: args.basepath + "socket.io", cookie: false });
300+
console.log(socketIo)
301+
302+
const io = socketIo(server, { path: args.basepath + "socket.io", cookie: false });
301303
io.sockets.on("connection", (socket) => initConnection(socket, prefix, args.hashsecret, args.ssl !== null));
302304

303305
console.log("Serving with prefix " + args.basepath + " on port " + args.port + ", secret: " + args.hashsecret);

0 commit comments

Comments
 (0)