mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-27 12:08:02 -05:00
fixed lib/utils.ts
- added more return types - removed module wrapper Signed-off-by: Philip Molares <philip.molares@udo.edu> Signed-off-by: David Mehren <dmehren1@gmail.com>
This commit is contained in:
parent
5c8541e65d
commit
b841b1ca4c
1 changed files with 45 additions and 48 deletions
27
lib/utils.ts
27
lib/utils.ts
|
@ -1,9 +1,10 @@
|
||||||
export module Utils {
|
import { Sequelize } from 'sequelize-typescript'
|
||||||
export function isSQLite(sequelize) {
|
|
||||||
return sequelize.options.dialect === 'sqlite'
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getImageMimeType(imagePath: string) {
|
export function isSQLite (sequelize: Sequelize): boolean {
|
||||||
|
return sequelize.options.dialect === 'sqlite'
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getImageMimeType (imagePath: string): string | undefined {
|
||||||
const fileExtension = /[^.]+$/.exec(imagePath)
|
const fileExtension = /[^.]+$/.exec(imagePath)
|
||||||
switch (fileExtension?.[0]) {
|
switch (fileExtension?.[0]) {
|
||||||
case 'bmp':
|
case 'bmp':
|
||||||
|
@ -22,17 +23,17 @@ export module Utils {
|
||||||
default:
|
default:
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// [Postgres] Handling NULL bytes
|
// [Postgres] Handling NULL bytes
|
||||||
// https://github.com/sequelize/sequelize/issues/6485
|
// https://github.com/sequelize/sequelize/issues/6485
|
||||||
export function stripNullByte(value) {
|
export function stripNullByte (value: string): string {
|
||||||
value = '' + value
|
value = '' + value
|
||||||
// eslint-disable-next-line no-control-regex
|
// eslint-disable-next-line no-control-regex
|
||||||
return value ? value.replace(/\u0000/g, '') : value
|
return value ? value.replace(/\u0000/g, '') : value
|
||||||
}
|
}
|
||||||
|
|
||||||
export function processData (data, _default, process?) {
|
export function processData (data, _default, process?) {
|
||||||
if (data === undefined) return data
|
if (data === undefined) return data
|
||||||
else if (process) {
|
else if (process) {
|
||||||
if (data === null) {
|
if (data === null) {
|
||||||
|
@ -47,8 +48,4 @@ export module Utils {
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue