diff --git a/src/Ombi/ClientApp/app/services/settings.service.ts b/src/Ombi/ClientApp/app/services/settings.service.ts index f6f770a19..726c86d63 100644 --- a/src/Ombi/ClientApp/app/services/settings.service.ts +++ b/src/Ombi/ClientApp/app/services/settings.service.ts @@ -279,4 +279,7 @@ export class SettingsService extends ServiceHelpers { return this.http .post(`${this.url}/notifications/newsletter`, JSON.stringify(settings), {headers: this.headers}); } + public verifyUrl(url: string): Observable { + return this.http.post(`${this.url}/customization/urlverify`, JSON.stringify({url}), {headers: this.headers}); + } } diff --git a/src/Ombi/ClientApp/app/settings/customization/customization.component.ts b/src/Ombi/ClientApp/app/settings/customization/customization.component.ts index c4cb32675..77e9a16bd 100644 --- a/src/Ombi/ClientApp/app/settings/customization/customization.component.ts +++ b/src/Ombi/ClientApp/app/settings/customization/customization.component.ts @@ -43,13 +43,24 @@ export class CustomizationComponent implements OnInit { } public save() { - this.settingsService.saveCustomization(this.settings).subscribe(x => { - if (x) { - this.notificationService.success("Successfully saved Ombi settings"); - } else { - this.notificationService.success("There was an error when saving the Ombi settings"); + + this.settingsService.verifyUrl(this.settings.applicationUrl).subscribe(x => { + if(this.settings.applicationUrl) { + if(!x) { + this.notificationService.error(`The URL "${this.settings.applicationUrl}" is not valid. Please format it correctly e.g. http://www.google.com/`); + return; + } } + + this.settingsService.saveCustomization(this.settings).subscribe(x => { + if (x) { + this.notificationService.success("Successfully saved Ombi settings"); + } else { + this.notificationService.success("There was an error when saving the Ombi settings"); + } + }); }); + } public dropDownChange(event: any): void { diff --git a/src/Ombi/Controllers/SettingsController.cs b/src/Ombi/Controllers/SettingsController.cs index 6f013b9c1..895621ad3 100644 --- a/src/Ombi/Controllers/SettingsController.cs +++ b/src/Ombi/Controllers/SettingsController.cs @@ -39,16 +39,6 @@ namespace Ombi.Controllers [Produces("application/json")] public class SettingsController : Controller { - /// - /// Initializes a new instance of the class. - /// - /// The resolver. - /// The mapper. - /// The templateRepo. - /// The embyApi. - /// The radarrCacher. - /// The memory cache. - /// The memory cache. public SettingsController(ISettingsResolver resolver, IMapper mapper, INotificationTemplatesRepository templateRepo, @@ -228,6 +218,13 @@ namespace Ombi.Controllers return await Save(settings); } + [ApiExplorerSettings(IgnoreApi = true)] + [HttpPost("customization/urlverify")] + public bool VerifyUrl([FromBody]UrlVerifyModel url) + { + return Uri.TryCreate(url.Url, UriKind.Absolute, out var __); + } + /// /// Get's the preset themes available /// diff --git a/src/Ombi/Models/UrlVerifyModel.cs b/src/Ombi/Models/UrlVerifyModel.cs new file mode 100644 index 000000000..01fdb0559 --- /dev/null +++ b/src/Ombi/Models/UrlVerifyModel.cs @@ -0,0 +1,7 @@ +namespace Ombi.Models +{ + public class UrlVerifyModel + { + public string Url { get; set; } + } +} \ No newline at end of file