Archived
1
0

feat(testing): refactor humanPath and add tests (#4511)

* feat: add test for humanPath

* refactor: make humanPath pure and pass in homedir
This commit is contained in:
Joe Previte
2021-11-15 19:40:34 +00:00
committed by GitHub
parent 16a5f2e171
commit 0a072f7532
5 changed files with 31 additions and 12 deletions

View File

@ -1,6 +1,7 @@
import { Router, Request } from "express"
import { promises as fs } from "fs"
import { RateLimiter as Limiter } from "limiter"
import * as os from "os"
import * as path from "path"
import { rootPath } from "../constants"
import { authenticated, getCookieDomain, redirect, replaceTemplates } from "../http"
@ -30,7 +31,7 @@ export class RateLimiter {
const getRoot = async (req: Request, error?: Error): Promise<string> => {
const content = await fs.readFile(path.join(rootPath, "src/browser/pages/login.html"), "utf8")
let passwordMsg = `Check the config file at ${humanPath(req.args.config)} for the password.`
let passwordMsg = `Check the config file at ${humanPath(os.homedir(), req.args.config)} for the password.`
if (req.args.usingEnvPassword) {
passwordMsg = "Password was set from $PASSWORD."
} else if (req.args.usingEnvHashedPassword) {