You've already forked pigallery2
mirror of
https://github.com/bpatrik/pigallery2.git
synced 2025-12-07 23:23:49 +02:00
improving base url handling
This commit is contained in:
@@ -17,6 +17,8 @@ import {I18n} from '@ngx-translate/i18n-polyfill';
|
||||
export class BasicSettingsComponent extends SettingsComponent<BasicConfigDTO> {
|
||||
|
||||
urlPlaceholder = location.origin;
|
||||
urlBaseChanged = false;
|
||||
urlError = false;
|
||||
|
||||
constructor(_authService: AuthenticationService,
|
||||
_navigation: NavigationService,
|
||||
@@ -30,6 +32,7 @@ export class BasicSettingsComponent extends SettingsComponent<BasicConfigDTO> {
|
||||
publicUrl: s.Client.publicUrl,
|
||||
urlBase: s.Client.urlBase
|
||||
}));
|
||||
this.checkUrlError();
|
||||
}
|
||||
|
||||
public async save(): Promise<boolean> {
|
||||
@@ -40,6 +43,42 @@ export class BasicSettingsComponent extends SettingsComponent<BasicConfigDTO> {
|
||||
return val;
|
||||
}
|
||||
|
||||
calcBaseUrl(): string {
|
||||
console.log(this.settings.publicUrl.replace(new RegExp('\\\\', 'g'), '/'));
|
||||
console.log(this.settings.publicUrl.replace(new RegExp('\\\\', 'g'), '/')
|
||||
.replace(new RegExp('http://', 'g'), ''));
|
||||
console.log(this.settings.publicUrl.replace(new RegExp('\\\\', 'g'), '/')
|
||||
.replace(new RegExp('http://', 'g'), '')
|
||||
.replace(new RegExp('https://', 'g'), ''));
|
||||
const url = this.settings.publicUrl.replace(new RegExp('\\\\', 'g'), '/')
|
||||
.replace(new RegExp('http://', 'g'), '')
|
||||
.replace(new RegExp('https://', 'g'), '');
|
||||
if (url.indexOf('/') !== -1) {
|
||||
return url.substring(url.indexOf('/'));
|
||||
}
|
||||
return '';
|
||||
|
||||
}
|
||||
|
||||
checkUrlError() {
|
||||
this.urlError = this.settings.urlBase !== this.calcBaseUrl();
|
||||
}
|
||||
|
||||
onUrlChanged() {
|
||||
if (this.urlBaseChanged === false) {
|
||||
this.settings.urlBase = this.calcBaseUrl();
|
||||
} else {
|
||||
this.checkUrlError();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onUrlBaseChanged() {
|
||||
this.urlBaseChanged = true;
|
||||
|
||||
this.checkUrlError();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user