aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/core-utils.ts9
1 files changed, 8 insertions, 1 deletions
diff --git a/server/helpers/core-utils.ts b/server/helpers/core-utils.ts
index 4981bb4ec..77547c528 100644
--- a/server/helpers/core-utils.ts
+++ b/server/helpers/core-utils.ts
@@ -8,7 +8,7 @@ import * as createTorrent from 'create-torrent'
8import { pseudoRandomBytes } from 'crypto' 8import { pseudoRandomBytes } from 'crypto'
9import { readdir, readFile, rename, stat, Stats, unlink, writeFile } from 'fs' 9import { readdir, readFile, rename, stat, Stats, unlink, writeFile } from 'fs'
10import * as mkdirp from 'mkdirp' 10import * as mkdirp from 'mkdirp'
11import { join } from 'path' 11import { isAbsolute, join } from 'path'
12import * as pem from 'pem' 12import * as pem from 'pem'
13import * as rimraf from 'rimraf' 13import * as rimraf from 'rimraf'
14import { URL } from 'url' 14import { URL } from 'url'
@@ -70,6 +70,12 @@ function pageToStartAndCount (page: number, itemsPerPage: number) {
70 return { start, count: itemsPerPage } 70 return { start, count: itemsPerPage }
71} 71}
72 72
73function buildPath (path: string) {
74 if (isAbsolute(path)) return path
75
76 return join(root(), path)
77}
78
73function promisify0<A> (func: (cb: (err: any, result: A) => void) => void): () => Promise<A> { 79function promisify0<A> (func: (cb: (err: any, result: A) => void) => void): () => Promise<A> {
74 return function promisified (): Promise<A> { 80 return function promisified (): Promise<A> {
75 return new Promise<A>((resolve: (arg: A) => void, reject: (err: any) => void) => { 81 return new Promise<A>((resolve: (arg: A) => void, reject: (err: any) => void) => {
@@ -136,6 +142,7 @@ export {
136 pageToStartAndCount, 142 pageToStartAndCount,
137 sanitizeUrl, 143 sanitizeUrl,
138 sanitizeHost, 144 sanitizeHost,
145 buildPath,
139 146
140 promisify0, 147 promisify0,
141 promisify1, 148 promisify1,