Skip to content

Commit

Permalink
Adjust sanitization and logging
Browse files Browse the repository at this point in the history
  • Loading branch information
kj800x committed Nov 19, 2021
1 parent 3989776 commit 6d121b9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion localproxy-client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import path from "path";
tmp.setGracefulCleanup();

const LOCALPROXY_CONFIG_DIR = "/etc/localproxy/sites";
const sanitize = (s: string) => s.replace(/[^a-z0-9]/gi, "_");
const sanitize = (s: string) => s.replace(/[^a-z0-9-]/gi, "-");
let tmpFileCleanups: { [key: string]: () => void } = {};

export type RouteType = "ui" | "api" | "data";
Expand Down
4 changes: 3 additions & 1 deletion localproxy-server/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const WATCH_DIR = "/etc/localproxy/sites";
let apps = {};
let onSyncHandler = () => {};

const sanitize = (s) => s.replace(/[^a-z0-9]/gi, "_");
const sanitize = (s) => s.replace(/[^a-z0-9-]/gi, "-");

const forceSync = () => {
const files = fs.readdirSync(WATCH_DIR);
Expand Down Expand Up @@ -52,6 +52,8 @@ function deRegister(id) {
const file = `${sanitize(id)}.json`;
if (fs.existsSync(path.join(WATCH_DIR, file))) {
fs.unlinkSync(path.join(WATCH_DIR, file));
} else {
console.warn(`Unable to deregister ${id}, does a ${file} file exist?`);
}
forceSync();
}
Expand Down

0 comments on commit 6d121b9

Please sign in to comment.