Trimed the frontend baseUrl if there is an extra forwardslash the end

pull/4072/head
tidusjar 4 years ago
parent b90ef2148b
commit 80a3dedf87

@ -201,12 +201,16 @@ namespace Ombi
SettingsName = "OmbiSettings",
Content = JsonConvert.SerializeObject(new OmbiSettings())
};
using (var tran = await settingsDb.Database.BeginTransactionAsync())
var strat = settingsDb.Database.CreateExecutionStrategy();
await strat.ExecuteAsync(async () =>
{
settingsDb.Add(ombiSettingsContent);
await settingsDb.SaveChangesAsync();
await tran.CommitAsync();
}
using (var tran = await settingsDb.Database.BeginTransactionAsync())
{
settingsDb.Add(ombiSettingsContent);
await settingsDb.SaveChangesAsync();
await tran.CommitAsync();
}
});
}
var ombiSettings = JsonConvert.DeserializeObject<OmbiSettings>(ombiSettingsContent.Content);
if (ombiSettings == null)
@ -220,12 +224,16 @@ namespace Ombi
};
ombiSettingsContent.Content = JsonConvert.SerializeObject(ombiSettings);
using (var tran = await settingsDb.Database.BeginTransactionAsync())
var strat = settingsDb.Database.CreateExecutionStrategy();
await strat.ExecuteAsync(async () =>
{
settingsDb.Update(ombiSettingsContent);
await settingsDb.SaveChangesAsync();
await tran.CommitAsync();
}
using (var tran = await settingsDb.Database.BeginTransactionAsync())
{
settingsDb.Update(ombiSettingsContent);
await settingsDb.SaveChangesAsync();
await tran.CommitAsync();
}
});
}
}
else if (baseUrl.HasValue() && !baseUrl.Equals(ombiSettings.BaseUrl))
@ -234,17 +242,22 @@ namespace Ombi
ombiSettings.BaseUrl = baseUrl;
ombiSettingsContent.Content = JsonConvert.SerializeObject(ombiSettings);
using (var tran = await settingsDb.Database.BeginTransactionAsync())
var strat = settingsDb.Database.CreateExecutionStrategy();
await strat.ExecuteAsync(async () =>
{
settingsDb.Update(ombiSettingsContent);
await settingsDb.SaveChangesAsync();
await tran.CommitAsync();
}
using (var tran = await settingsDb.Database.BeginTransactionAsync())
{
settingsDb.Update(ombiSettingsContent);
await settingsDb.SaveChangesAsync();
await tran.CommitAsync();
}
});
}
if (setBaseUrl)
{
var trimmedBaseUrl = baseUrl.EndsWith('/') ? baseUrl.TrimEnd('/') : baseUrl;
var process = Process.GetCurrentProcess().MainModule.FileName;
var ombiInstalledDir = Path.GetDirectoryName(process);
var indexPath = Path.Combine(ombiInstalledDir, "ClientApp", "dist", "index.html");
@ -256,7 +269,7 @@ namespace Ombi
}
var indexHtml = await File.ReadAllTextAsync(indexPath);
indexHtml = indexHtml.Replace("<script type='text/javascript'>window[\"baseHref\"] = '/';</script>"
, $"<script type='text/javascript'>window[\"baseHref\"] = '{baseUrl}';</script><base href=\"{baseUrl}\">", StringComparison.InvariantCultureIgnoreCase);
, $"<script type='text/javascript'>window[\"baseHref\"] = '{trimmedBaseUrl}';</script><base href=\"{baseUrl}\">", StringComparison.InvariantCultureIgnoreCase);
await File.WriteAllTextAsync(indexPath, indexHtml);

Loading…
Cancel
Save