mirror of
https://github.com/bpatrik/pigallery2.git
synced 2024-12-10 11:10:35 +02:00
This commit is contained in:
parent
0c2a21145f
commit
a8d636776b
@ -98,7 +98,7 @@ export class RenderingMWs {
|
||||
delete (err.details); // do not send back error object to the client side
|
||||
|
||||
// hide error details for non developers
|
||||
if (!(req.session.user && req.session.user.role >= UserRoles.Developer)) {
|
||||
if (!(req.session && req.session.user && req.session.user.role >= UserRoles.Developer)) {
|
||||
delete (err.detailsStr);
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ export class Utils {
|
||||
.replace(new RegExp('/+', 'g'), '/');
|
||||
}
|
||||
|
||||
static concatUrls(...args: Array<string>): string {
|
||||
static concatUrls(...args: string[]): string {
|
||||
let url = '';
|
||||
for (const item of args) {
|
||||
if (item === '' || typeof item === 'undefined') {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import {Utils} from '../../../../common/Utils';
|
||||
import {MediaIcon} from './MediaIcon';
|
||||
import {Config} from '../../../../common/config/public/Config';
|
||||
import {MediaBaseDTO, MediaDTO, MediaDTOUtils} from '../../../../common/entities/MediaDTO';
|
||||
import {MediaBaseDTO, MediaDTOUtils} from '../../../../common/entities/MediaDTO';
|
||||
|
||||
export class Media extends MediaIcon {
|
||||
|
||||
@ -54,8 +54,7 @@ export class Media extends MediaIcon {
|
||||
getReplacementThumbnailPath(): string {
|
||||
const size = this.getReplacementThumbnailSize();
|
||||
return Utils.concatUrls(Config.Client.urlBase,
|
||||
'/api/gallery/content/',
|
||||
this.media.directory.path, this.media.directory.name, this.media.name, 'thumbnail', size.toString());
|
||||
'/api/gallery/content/', this.getRelativePath(), 'thumbnail', size.toString());
|
||||
|
||||
}
|
||||
|
||||
@ -66,8 +65,7 @@ export class Media extends MediaIcon {
|
||||
getThumbnailPath(): string {
|
||||
const size = this.getThumbnailSize();
|
||||
return Utils.concatUrls(Config.Client.urlBase,
|
||||
'/api/gallery/content/',
|
||||
this.media.directory.path, this.media.directory.name, this.media.name, 'thumbnail', size.toString());
|
||||
'/api/gallery/content/', this.getRelativePath(), 'thumbnail', size.toString());
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,19 +24,25 @@ export class MediaIcon {
|
||||
}
|
||||
|
||||
getRelativePath(): string {
|
||||
return Utils.concatUrls(this.media.directory.path, this.media.directory.name, this.media.name);
|
||||
return Utils.concatUrls(this.media.directory.path,
|
||||
this.media.directory.name,
|
||||
this.media.name)
|
||||
// do not escape all urls with encodeURIComponent because that make the URL ugly and not needed
|
||||
// do not escape before concatUrls as that would make prevent optimizations
|
||||
.replace(new RegExp('%', 'g'), '%25') // order important
|
||||
.replace(new RegExp('#', 'g'), '%23')
|
||||
.replace(new RegExp('\\$', 'g'), '%24');
|
||||
}
|
||||
|
||||
getIconPath(): string {
|
||||
return Utils.concatUrls(Config.Client.urlBase,
|
||||
'/api/gallery/content/',
|
||||
this.media.directory.path, this.media.directory.name, this.media.name, 'icon');
|
||||
this.getRelativePath(), 'icon');
|
||||
}
|
||||
|
||||
getMediaPath(): string {
|
||||
return Utils.concatUrls(Config.Client.urlBase,
|
||||
'/api/gallery/content/',
|
||||
this.media.directory.path, this.media.directory.name, this.media.name);
|
||||
'/api/gallery/content/', this.getRelativePath());
|
||||
}
|
||||
|
||||
getBestFitMediaPath(): string {
|
||||
|
Loading…
Reference in New Issue
Block a user