mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-19 09:42:29 +08:00
Upgrade host resolution (#8387)
* Reverted changes to RunningShellTable and then changed the way shells are sorted, so we can correctly give "priority" to tenants based on their prefix. Added test adapter reference to Orchard.Framework.Tests so tests can be run in the latest VS 2017. Fixed a test that was failing to account for the order the shells were being processed. * Removed some stuff from csproj that vs had added
This commit is contained in:
committed by
GitHub
parent
b528ecd1e0
commit
f67e6b3695
@@ -128,9 +128,10 @@ namespace Orchard.Tests.Environment {
|
||||
var settingsG = new ShellSettings { Name = "Gamma", RequestUrlHost = "wiki.example.com" };
|
||||
var settingsD = new ShellSettings { Name = "Delta", RequestUrlPrefix = "Quux" };
|
||||
table.Add(settings);
|
||||
// add this shell first, because the order the shells where processed used to matter
|
||||
table.Add(settingsG);
|
||||
table.Add(settingsA);
|
||||
table.Add(settingsB);
|
||||
table.Add(settingsG);
|
||||
table.Add(settingsD);
|
||||
|
||||
Assert.That(table.Match(new StubHttpContext("~/foo/bar", "wiki.example.com")), Is.EqualTo(settingsA).Using(new ShellComparer()));
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\NUnitTestAdapter.2.3.0\build\NUnitTestAdapter.props" Condition="Exists('..\packages\NUnitTestAdapter.2.3.0\build\NUnitTestAdapter.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
|
||||
@@ -17,4 +17,5 @@
|
||||
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net452" />
|
||||
<package id="NHibernate" version="4.0.1.4000" targetFramework="net452" />
|
||||
<package id="NUnit" version="2.5.10.11092" targetFramework="net452" />
|
||||
<package id="NUnitTestAdapter" version="2.3.0" targetFramework="net452" />
|
||||
</packages>
|
||||
@@ -84,7 +84,12 @@ namespace Orchard.Environment {
|
||||
.Select(h => new ShellSettings(s) {RequestUrlHost = h}))
|
||||
.GroupBy(s => s.RequestUrlHost ?? string.Empty)
|
||||
.OrderByDescending(g => g.Key.Length)
|
||||
.ToDictionary(x => x.Key, x => x.AsEnumerable(), StringComparer.OrdinalIgnoreCase);
|
||||
.ToDictionary(
|
||||
x => x.Key,
|
||||
// we want to keep this ordered so that, for the same host, shells with a configured
|
||||
// RequestUrlPrefix are tested first when trying to match them to coming requests.
|
||||
x => x.OrderByDescending(ss => (ss.RequestUrlPrefix ?? "").Length).AsEnumerable(),
|
||||
StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
if (unqualified.Count() == 1) {
|
||||
// only one shell had no request url criteria
|
||||
|
||||
Reference in New Issue
Block a user