refactor: 应用程序保存地址增加 / 符号去除功能
This commit is contained in:
parent
c6f32ddff8
commit
d1e8e104c6
|
@ -169,7 +169,9 @@ namespace Bootstrap.DataAccess
|
||||||
{
|
{
|
||||||
Category = "网站设置",
|
Category = "网站设置",
|
||||||
Name = cache[i.Name],
|
Name = cache[i.Name],
|
||||||
Code = i.Code
|
|
||||||
|
// 后台网站配置不能以 / 号结尾
|
||||||
|
Code = i.Name == "AppPath" ? i.Code.TrimEnd('/') : i.Code
|
||||||
}));
|
}));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -377,6 +379,9 @@ namespace Bootstrap.DataAccess
|
||||||
{
|
{
|
||||||
// dict define == 1 时为新建前台应用
|
// dict define == 1 时为新建前台应用
|
||||||
bool ret;
|
bool ret;
|
||||||
|
|
||||||
|
// 前台网站配置地址 不允许以 / 结尾
|
||||||
|
dict.Code = dict.Code.TrimEnd('/');
|
||||||
if (dict.Define == 0)
|
if (dict.Define == 0)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
|
|
|
@ -44,6 +44,39 @@ namespace Bootstrap.Admin.Api
|
||||||
DictHelper.Delete(ids);
|
DictHelper.Delete(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async void Post_Id_Ok()
|
||||||
|
{
|
||||||
|
// Demo
|
||||||
|
var resp = await Client.PostAsJsonAsync<BootstrapDict, bool>("Demo", new BootstrapDict() { Name = "1", Code = "UnitTest" });
|
||||||
|
Assert.False(resp);
|
||||||
|
|
||||||
|
// AppPath
|
||||||
|
var dict = new BootstrapDict() { Category = "UnitTest", Name = "UnitTest", Code = "http://localhost/AppPath/" };
|
||||||
|
resp = await Client.PostAsJsonAsync<BootstrapDict, bool>("AppPath", dict);
|
||||||
|
Assert.True(resp);
|
||||||
|
|
||||||
|
Assert.Equal(dict.Code.TrimEnd('/'), DictHelper.RetrieveDicts().FirstOrDefault(d => d.Category == "应用首页" && d.Name == dict.Name)?.Code ?? "");
|
||||||
|
|
||||||
|
// update by set dict.Define = 0
|
||||||
|
dict.Define = 0;
|
||||||
|
dict.Code = "http://127.0.0.1/UnitTest";
|
||||||
|
resp = await Client.PostAsJsonAsync<BootstrapDict, bool>("AppPath", dict);
|
||||||
|
Assert.True(resp);
|
||||||
|
|
||||||
|
Assert.Equal(dict.Code.TrimEnd('/'), DictHelper.RetrieveDicts().FirstOrDefault(d => d.Category == "应用首页" && d.Name == dict.Name)?.Code ?? "");
|
||||||
|
|
||||||
|
// del
|
||||||
|
dict.Name = "UnitTest";
|
||||||
|
dict.Code = "UnitTest";
|
||||||
|
resp = await Client.DeleteAsJsonAsync<BootstrapDict, bool>("AppPath", dict);
|
||||||
|
Assert.True(resp);
|
||||||
|
|
||||||
|
// Else
|
||||||
|
resp = await Client.PostAsJsonAsync<BootstrapDict, bool>("UnitTest", dict);
|
||||||
|
Assert.False(resp);
|
||||||
|
}
|
||||||
|
|
||||||
internal class CacheCorsItem : ICacheCorsItem
|
internal class CacheCorsItem : ICacheCorsItem
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue