-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
V2 - Added template URl and dynamic placeholders
- Loading branch information
1 parent
76d6056
commit 2a02126
Showing
22 changed files
with
201 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
V2 uses a template URL in combination with placeholders to give you full flexibility to build exactly the preview URL you want. | ||
|
||
## Added | ||
- New template URL concept with dynamic placeholder values | ||
- Hostname is selected based on the culture you are previewing |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions
24
src/Our.Umbraco.HeadlessPreview.Tests/Our.Umbraco.HeadlessPreview.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" /> | ||
<PackageReference Include="NUnit" Version="3.13.3" /> | ||
<PackageReference Include="NUnit3TestAdapter" Version="4.3.0" /> | ||
<PackageReference Include="NUnit.Analyzers" Version="3.5.0" /> | ||
<PackageReference Include="coverlet.collector" Version="3.1.2" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Our.Umbraco.HeadlessPreview\Our.Umbraco.HeadlessPreview.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
40 changes: 40 additions & 0 deletions
40
src/Our.Umbraco.HeadlessPreview.Tests/Services/TemplateUrlParserTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using NUnit.Framework; | ||
using Our.Umbraco.HeadlessPreview.Models; | ||
using Our.Umbraco.HeadlessPreview.Services; | ||
|
||
namespace Our.Umbraco.HeadlessPreview.Tests.Services; | ||
|
||
public class TemplateUrlParserTest | ||
{ | ||
[Test] | ||
[TestCase("https://test.local/api/preview?slug={slug}", ExpectedResult = new[] { TemplateUrlPlaceHolder.Slug })] | ||
[TestCase("https://test.local/api/preview?slug={SLUG}", ExpectedResult = new[] { TemplateUrlPlaceHolder.Slug })] | ||
[TestCase("{hostname}/api/preview", ExpectedResult = new[] { TemplateUrlPlaceHolder.Hostname })] | ||
[TestCase("{HOSTNAME}/api/preview", ExpectedResult = new[] { TemplateUrlPlaceHolder.Hostname })] | ||
[TestCase("{hostname}/api/preview?slug={slug}", ExpectedResult = new[] { TemplateUrlPlaceHolder.Hostname, TemplateUrlPlaceHolder.Slug })] | ||
[TestCase("{HOSTNAME}/api/preview?slug={SLUG}", ExpectedResult = new [] { TemplateUrlPlaceHolder.Hostname, TemplateUrlPlaceHolder.Slug })] | ||
public TemplateUrlPlaceHolder[] GetPlaceHolders_Returns_Placeholders(string templateUrl) | ||
{ | ||
var subject = new TemplateUrlParser(); | ||
|
||
var result = subject.GetPlaceHolders(templateUrl); | ||
|
||
return result; | ||
} | ||
|
||
[Test] | ||
[TestCase("https://test.local/api/preview?slug={slug}", null, "/testpage", ExpectedResult = "https://test.local/api/preview?slug=/testpage")] | ||
[TestCase("https://test.local/api/preview?slug={SLUG}", null, "/testpage", ExpectedResult = "https://test.local/api/preview?slug=/testpage")] | ||
[TestCase("{hostname}/api/preview", "https://test.local", null, ExpectedResult = "https://test.local/api/preview")] | ||
[TestCase("{HOSTNAME}/api/preview", "https://test.local", null, ExpectedResult = "https://test.local/api/preview")] | ||
[TestCase("{hostname}/api/preview?slug={slug}", "https://test.local", "/testpage", ExpectedResult = "https://test.local/api/preview?slug=/testpage")] | ||
[TestCase("{HOSTNAME}/api/preview?slug={SLUG}", "https://test.local", "/testpage", ExpectedResult = "https://test.local/api/preview?slug=/testpage")] | ||
public string Parse_Returns_Parsed_Url(string templateUrl, string hostname, string slug) | ||
{ | ||
var subject = new TemplateUrlParser(); | ||
|
||
var result = subject.Parse(templateUrl, hostname, slug); | ||
|
||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.