mirror of https://github.com/tycrek/ass
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
1.0 KiB
29 lines
1.0 KiB
const { HTTP, HTTPS } = require('../MagicNumbers.json');
|
|
|
|
export function getTrueHttp() {
|
|
return ('http').concat(useSsl ? 's' : '').concat('://');
|
|
}
|
|
|
|
export function getTrueDomain(d = domain) {
|
|
return d.concat((port === HTTP || port === HTTPS || isProxied) ? '' : `:${port}`);
|
|
}
|
|
|
|
export function getS3url(s3key: string, ext: string) {
|
|
return `https://${s3usePathStyle ? `${s3endpoint}/${s3bucket}` : `${s3bucket}.${s3endpoint}`}/${s3key}${ext}`;
|
|
}
|
|
|
|
export function getDirectUrl(resourceId: string) {
|
|
return `${getTrueHttp()}${getTrueDomain()}/${resourceId}/direct`;
|
|
}
|
|
|
|
export function getResourceColor(colorValue: string, vibrantValue: string) {
|
|
return (!colorValue || colorValue === '&vibrant') ? vibrantValue : colorValue === '&random' ? randomHexColour() : colorValue;
|
|
}
|
|
|
|
export function replaceholder(data: string, size: number, timestamp: number, timeoffset: string, originalname: string) {
|
|
return data
|
|
.replace(/&size/g, formatBytes(size))
|
|
.replace(/&filename/g, originalname)
|
|
.replace(/×tamp/g, formatTimestamp(timestamp, timeoffset));
|
|
}
|