Skip to content

Commit

Permalink
Replace full url.
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStehle committed May 21, 2022
1 parent 471e711 commit 59347cd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion cli/Squidex.CLI/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/Squidex/squidex/</PackageProjectUrl>
<PackageTags>Squidex HeadlessCMS</PackageTags>
<Version>8.15</Version>
<Version>8.16</Version>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,20 @@ public static void MapComponents(this ContentModel model, Dictionary<string, str
public sealed class Mapper
{
private readonly string url;
private readonly string pathToAssets;
private readonly string pathToContent;
private readonly string urlToAssets;
private readonly string urlToContent;
private readonly HashSet<string>? languages;
private string? sourceUrl;
private string? sourceApp;
private string? sourcePathToAssets;
private string? sourcePathToContent;
private string? sourceUrl;
private string? sourceUrlToAssets;
private string? sourceUrlToContent;

public Mapper(string url, string app, string[]? languages)
{
this.url = url.TrimEnd('/');

pathToAssets = $"api/assets/{app}/";
pathToContent = $"api/content/{app}/";
urlToAssets = $"{this.url}/api/assets/{app}/";
urlToContent = $"{this.url}/api/content/{app}/";

this.languages = languages?.ToHashSet();
}
Expand All @@ -86,8 +86,8 @@ public void Map(ContentsModel model)

if (sourceApp != null)
{
sourcePathToAssets = $"api/assets/{sourceApp}/";
sourcePathToContent = $"api/content/{sourceApp}/";
sourceUrlToAssets = $"{sourceUrl}/api/assets/{sourceApp}/";
sourceUrlToContent = $"{sourceUrl}/api/content/{sourceApp}/";
}
}

Expand All @@ -113,19 +113,19 @@ private void MapStrings(ContentModel content)
return value;
}

if (sourceUrl != null)
if (sourceUrlToAssets != null)
{
value = value?.Replace(sourceUrl, url, StringComparison.OrdinalIgnoreCase);
value = value?.Replace(sourceUrlToAssets, urlToAssets, StringComparison.OrdinalIgnoreCase);
}

if (sourcePathToAssets != null)
if (sourceUrlToContent != null)
{
value = value?.Replace(sourcePathToAssets, pathToAssets, StringComparison.OrdinalIgnoreCase);
value = value?.Replace(sourceUrlToContent, urlToContent, StringComparison.OrdinalIgnoreCase);
}

if (sourcePathToContent != null)
if (sourceUrl != null)
{
value = value?.Replace(sourcePathToContent, pathToContent, StringComparison.OrdinalIgnoreCase);
value = value?.Replace(sourceUrl, url, StringComparison.OrdinalIgnoreCase);
}

return value;
Expand Down

0 comments on commit 59347cd

Please sign in to comment.