fix incorrect link URLs in some cases
This commit is contained in:
parent
5f532c259d
commit
8a11d5c0d9
|
@ -151,7 +151,7 @@ namespace StardewModdingAPI.Web.Controllers
|
|||
return this.View("Index", new JsonValidatorModel(result.ID, schemaName, this.SchemaFormats).SetUploadError($"Pastebin error: {result.Error ?? "unknown error"}"));
|
||||
|
||||
// redirect to view
|
||||
return this.Redirect(this.Url.Action("Index", "LogParser", new { schemaName = schemaName, id = result.ID }));
|
||||
return this.Redirect(this.Url.PlainAction("Index", "LogParser", new { schemaName = schemaName, id = result.ID }));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ namespace StardewModdingAPI.Web.Controllers
|
|||
return this.View("Index", this.GetModel(null, uploadError: uploadResult.UploadError));
|
||||
|
||||
// redirect to view
|
||||
return this.Redirect(this.Url.Action("Index", "LogParser", new { id = uploadResult.ID }));
|
||||
return this.Redirect(this.Url.PlainAction("Index", "LogParser", new { id = uploadResult.ID }));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ using StardewModdingAPI.Toolkit.Framework.Clients.WebApi;
|
|||
using StardewModdingAPI.Toolkit.Framework.Clients.Wiki;
|
||||
using StardewModdingAPI.Toolkit.Framework.ModData;
|
||||
using StardewModdingAPI.Toolkit.Framework.UpdateData;
|
||||
using StardewModdingAPI.Web.Framework;
|
||||
using StardewModdingAPI.Web.Framework.Caching.Mods;
|
||||
using StardewModdingAPI.Web.Framework.Caching.Wiki;
|
||||
using StardewModdingAPI.Web.Framework.Clients.Chucklefish;
|
||||
|
@ -201,7 +202,7 @@ namespace StardewModdingAPI.Web.Controllers
|
|||
|
||||
// get unofficial version
|
||||
if (wikiEntry?.Compatibility.UnofficialVersion != null && this.IsNewer(wikiEntry.Compatibility.UnofficialVersion, main?.Version) && this.IsNewer(wikiEntry.Compatibility.UnofficialVersion, optional?.Version))
|
||||
unofficial = new ModEntryVersionModel(wikiEntry.Compatibility.UnofficialVersion, $"{this.Url.Action("Index", "Mods")}#{wikiEntry.Anchor}");
|
||||
unofficial = new ModEntryVersionModel(wikiEntry.Compatibility.UnofficialVersion, $"{this.Url.PlainAction("Index", "Mods")}#{wikiEntry.Anchor}");
|
||||
|
||||
// get unofficial version for beta
|
||||
if (wikiEntry?.HasBetaInfo == true)
|
||||
|
@ -211,7 +212,7 @@ namespace StardewModdingAPI.Web.Controllers
|
|||
if (wikiEntry.BetaCompatibility.UnofficialVersion != null)
|
||||
{
|
||||
unofficialForBeta = (wikiEntry.BetaCompatibility.UnofficialVersion != null && this.IsNewer(wikiEntry.BetaCompatibility.UnofficialVersion, main?.Version) && this.IsNewer(wikiEntry.BetaCompatibility.UnofficialVersion, optional?.Version))
|
||||
? new ModEntryVersionModel(wikiEntry.BetaCompatibility.UnofficialVersion, $"{this.Url.Action("Index", "Mods")}#{wikiEntry.Anchor}")
|
||||
? new ModEntryVersionModel(wikiEntry.BetaCompatibility.UnofficialVersion, $"{this.Url.PlainAction("Index", "Mods")}#{wikiEntry.Anchor}")
|
||||
: null;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
using JetBrains.Annotations;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
|
||||
namespace StardewModdingAPI.Web.Framework
|
||||
{
|
||||
/// <summary>Provides extensions on ASP.NET Core types.</summary>
|
||||
public static class Extensions
|
||||
{
|
||||
/// <summary>Get a URL with the absolute path for an action method. Unlike <see cref="IUrlHelper.Action"/>, only the specified <paramref name="values"/> are added to the URL without merging values from the current HTTP request.</summary>
|
||||
/// <param name="helper">The URL helper to extend.</param>
|
||||
/// <param name="action">The name of the action method.</param>
|
||||
/// <param name="controller">The name of the controller.</param>
|
||||
/// <param name="values">An object that contains route values.</param>
|
||||
/// <returns>The generated URL.</returns>
|
||||
public static string PlainAction(this IUrlHelper helper, [AspMvcAction] string action, [AspMvcController] string controller, object values = null)
|
||||
{
|
||||
RouteValueDictionary valuesDict = new RouteValueDictionary(values);
|
||||
foreach (var value in helper.ActionContext.RouteData.Values)
|
||||
{
|
||||
if (!valuesDict.ContainsKey(value.Key))
|
||||
valuesDict[value.Key] = null; // explicitly remove it from the URL
|
||||
}
|
||||
|
||||
return helper.Action(action, controller, valuesDict);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,6 +17,7 @@
|
|||
<PackageReference Include="Hangfire.Mongo" Version="0.6.5" />
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.11.16" />
|
||||
<PackageReference Include="Humanizer.Core" Version="2.7.9" />
|
||||
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3" />
|
||||
<PackageReference Include="Markdig" Version="0.18.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
@using Microsoft.Extensions.Options
|
||||
@using StardewModdingAPI.Web.Framework
|
||||
@using StardewModdingAPI.Web.Framework.ConfigModels
|
||||
@inject IOptions<SiteConfig> SiteConfig
|
||||
@model StardewModdingAPI.Web.ViewModels.IndexModel
|
||||
|
@ -44,14 +45,14 @@
|
|||
}
|
||||
<div><a href="https://stardewvalleywiki.com/Modding:Player_Guide" class="secondary-cta">Player guide</a></div>
|
||||
<div class="sublinks">
|
||||
<a href="https://github.com/Pathoschild/SMAPI">source code</a> | <a href="@Url.Action("Privacy", "Index")">privacy</a>
|
||||
<a href="https://github.com/Pathoschild/SMAPI">source code</a> | <a href="@Url.PlainAction("Privacy", "Index")">privacy</a>
|
||||
</div>
|
||||
<img id="pufferchick" src="Content/images/pufferchick.png" />
|
||||
</div>
|
||||
|
||||
<h2 id="help">Get help</h2>
|
||||
<ul>
|
||||
<li><a href="@Url.Action("Index", "Mods")">Mod compatibility list</a></li>
|
||||
<li><a href="@Url.PlainAction("Index", "Mods")">Mod compatibility list</a></li>
|
||||
<li>Get help <a href="https://smapi.io/community">on Discord or in the forums</a></li>
|
||||
</ul>
|
||||
|
||||
|
@ -61,7 +62,7 @@
|
|||
<div class="github-description">
|
||||
@Html.Raw(Markdig.Markdown.ToHtml(Model.StableVersion.Description))
|
||||
</div>
|
||||
<p>See the <a href="https://github.com/Pathoschild/SMAPI/blob/develop/docs/release-notes.md#release-notes">release notes</a> and <a href="@Url.Action("Index", "Mods")">mod compatibility list</a> for more info.</p>
|
||||
<p>See the <a href="https://github.com/Pathoschild/SMAPI/blob/develop/docs/release-notes.md#release-notes">release notes</a> and <a href="@Url.PlainAction("Index", "Mods")">mod compatibility list</a> for more info.</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -70,13 +71,13 @@ else
|
|||
<div class="github-description">
|
||||
@Html.Raw(Markdig.Markdown.ToHtml(Model.StableVersion.Description))
|
||||
</div>
|
||||
<p>See the <a href="https://github.com/Pathoschild/SMAPI/blob/develop/docs/release-notes.md#release-notes">release notes</a> and <a href="@Url.Action("Index", "Mods")">mod compatibility list</a> for more info.</p>
|
||||
<p>See the <a href="https://github.com/Pathoschild/SMAPI/blob/develop/docs/release-notes.md#release-notes">release notes</a> and <a href="@Url.PlainAction("Index", "Mods")">mod compatibility list</a> for more info.</p>
|
||||
|
||||
<h3>SMAPI @Model.BetaVersion.Version?</h3>
|
||||
<div class="github-description">
|
||||
@Html.Raw(Markdig.Markdown.ToHtml(Model.BetaVersion.Description))
|
||||
</div>
|
||||
<p>See the <a href="https://github.com/Pathoschild/SMAPI/blob/develop/docs/release-notes.md#release-notes">release notes</a> and <a href="@Url.Action("Index", "Mods")">mod compatibility list</a> for more info.</p>
|
||||
<p>See the <a href="https://github.com/Pathoschild/SMAPI/blob/develop/docs/release-notes.md#release-notes">release notes</a> and <a href="@Url.PlainAction("Index", "Mods")">mod compatibility list</a> for more info.</p>
|
||||
}
|
||||
|
||||
<h2 id="donate">Support SMAPI ♥</h2>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
@using Microsoft.Extensions.Options
|
||||
@using StardewModdingAPI.Web.Framework
|
||||
@using StardewModdingAPI.Web.Framework.ConfigModels
|
||||
@inject IOptions<SiteConfig> SiteConfig
|
||||
@{
|
||||
|
@ -8,7 +9,7 @@
|
|||
<link rel="stylesheet" href="~/Content/css/privacy.css" />
|
||||
}
|
||||
|
||||
← <a href="@Url.Action("Index", "Index")">back to SMAPI page</a>
|
||||
← <a href="@Url.PlainAction("Index", "Index")">back to SMAPI page</a>
|
||||
|
||||
<p>SMAPI is an <a href="https://github.com/Pathoschild/SMAPI">open-source</a> and non-profit project. Your privacy is important, so this page explains what information SMAPI uses and transmits. <strong>This page is informational only, it's not a legal document.</strong></p>
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
@using StardewModdingAPI.Web.Framework
|
||||
@using StardewModdingAPI.Web.ViewModels.JsonValidator
|
||||
@model JsonValidatorModel
|
||||
|
||||
@{
|
||||
// get view data
|
||||
string curPageUrl = this.Url.Action("Index", "JsonValidator", new { schemaName = Model.SchemaName, id = Model.PasteID });
|
||||
string newUploadUrl = this.Url.Action("Index", "JsonValidator", new { schemaName = Model.SchemaName });
|
||||
string curPageUrl = this.Url.PlainAction("Index", "JsonValidator", new { schemaName = Model.SchemaName, id = Model.PasteID });
|
||||
string newUploadUrl = this.Url.PlainAction("Index", "JsonValidator", new { schemaName = Model.SchemaName });
|
||||
string schemaDisplayName = null;
|
||||
bool isValidSchema = Model.SchemaName != null && Model.SchemaFormats.TryGetValue(Model.SchemaName, out schemaDisplayName) && schemaDisplayName != "None";
|
||||
|
||||
|
@ -35,7 +36,7 @@
|
|||
<script src="~/Content/js/json-validator.js"></script>
|
||||
<script>
|
||||
$(function() {
|
||||
smapi.jsonValidator(@Json.Serialize(this.Url.Action("Index", "JsonValidator")), @Json.Serialize(Model.PasteID));
|
||||
smapi.jsonValidator(@Json.Serialize(this.Url.PlainAction("Index", "JsonValidator", values: null)), @Json.Serialize(Model.PasteID));
|
||||
});
|
||||
</script>
|
||||
}
|
||||
|
@ -70,7 +71,7 @@ else if (Model.PasteID != null)
|
|||
@if (Model.Content == null)
|
||||
{
|
||||
<h2>Upload a JSON file</h2>
|
||||
<form action="@this.Url.Action("PostAsync", "JsonValidator")" method="post">
|
||||
<form action="@this.Url.PlainAction("PostAsync", "JsonValidator")" method="post">
|
||||
<ol>
|
||||
<li>
|
||||
Choose the JSON format:<br />
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
@using Humanizer
|
||||
@using Newtonsoft.Json
|
||||
@using StardewModdingAPI.Toolkit.Utilities
|
||||
@using StardewModdingAPI.Web.Framework
|
||||
@using StardewModdingAPI.Web.Framework.LogParsing.Models
|
||||
@model StardewModdingAPI.Web.ViewModels.LogParserModel
|
||||
|
||||
|
@ -32,7 +33,7 @@
|
|||
showSections: @Json.Serialize(Enum.GetNames(typeof(LogSection)).ToDictionary(section => section, section => false), noFormatting),
|
||||
showLevels: @Json.Serialize(defaultFilters, noFormatting),
|
||||
enableFilters: @Json.Serialize(!Model.ShowRaw)
|
||||
}, '@this.Url.Action("Index", "LogParser")');
|
||||
}, '@this.Url.PlainAction("Index", "LogParser", values: null)');
|
||||
});
|
||||
</script>
|
||||
}
|
||||
|
@ -49,8 +50,8 @@ else if (Model.ParseError != null)
|
|||
{
|
||||
<div class="banner error" v-pre>
|
||||
<strong>Oops, couldn't parse that log. (Make sure you upload the log file, not the console text.)</strong><br />
|
||||
Share this URL when asking for help: <code>https://@this.Context.Request.Host.ToUriComponent()@this.Url.Action("Index", "LogParser", new { id = Model.PasteID }))</code><br />
|
||||
(Or <a href="@this.Url.Action("Index", "LogParser")">upload a new log</a>.)<br />
|
||||
Share this URL when asking for help: <code>https://@this.Context.Request.Host.ToUriComponent()@this.Url.PlainAction("Index", "LogParser", new { id = Model.PasteID }))</code><br />
|
||||
(Or <a href="@this.Url.PlainAction("Index", "LogParser", values: null)">upload a new log</a>.)<br />
|
||||
<br />
|
||||
<small v-pre>Error details: @Model.ParseError</small>
|
||||
</div>
|
||||
|
@ -58,8 +59,8 @@ else if (Model.ParseError != null)
|
|||
else if (Model.ParsedLog?.IsValid == true)
|
||||
{
|
||||
<div class="banner success" v-pre>
|
||||
<strong>Share this link to let someone else see the log:</strong> <code>https://@this.Context.Request.Host.ToUriComponent()@this.Url.Action("Index", "LogParser", new { id = Model.PasteID })</code><br />
|
||||
(Or <a href="@this.Url.Action("Index", "LogParser")">upload a new log</a>.)
|
||||
<strong>Share this link to let someone else see the log:</strong> <code>https://@this.Context.Request.Host.ToUriComponent()@this.Url.PlainAction("Index", "LogParser", new { id = Model.PasteID })</code><br />
|
||||
(Or <a href="@this.Url.PlainAction("Index", "LogParser", values: null)">upload a new log</a>.)
|
||||
</div>
|
||||
}
|
||||
|
||||
|
@ -127,7 +128,7 @@ else if (Model.ParsedLog?.IsValid == true)
|
|||
</div>
|
||||
|
||||
<h2>How do I share my log?</h2>
|
||||
<form action="@this.Url.Action("PostAsync", "LogParser")" method="post">
|
||||
<form action="@this.Url.PlainAction("PostAsync", "LogParser")" method="post">
|
||||
<ol>
|
||||
<li>
|
||||
Drag the file onto this textbox (or paste the text in):<br />
|
||||
|
@ -322,12 +323,12 @@ else if (Model.ParsedLog?.IsValid == true)
|
|||
}
|
||||
</table>
|
||||
|
||||
<small><a href="@this.Url.Action("Index", "LogParser", new { id = Model.PasteID })?raw=true">view raw log</a></small>
|
||||
<small><a href="@this.Url.PlainAction("Index", "LogParser", new { id = Model.PasteID, raw = true })">view raw log</a></small>
|
||||
}
|
||||
else
|
||||
{
|
||||
<pre v-pre>@Model.ParsedLog.RawText</pre>
|
||||
<small><a href="@this.Url.Action("Index", "LogParser", new { id = Model.PasteID })">view parsed log</a></small>
|
||||
<small><a href="@this.Url.PlainAction("Index", "LogParser", new { id = Model.PasteID })">view parsed log</a></small>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
@using Microsoft.Extensions.Options
|
||||
@using StardewModdingAPI.Web.Framework
|
||||
@using StardewModdingAPI.Web.Framework.ConfigModels
|
||||
@inject IOptions<SiteConfig> SiteConfig
|
||||
|
||||
|
@ -15,15 +16,15 @@
|
|||
<div id="sidebar">
|
||||
<h4>SMAPI</h4>
|
||||
<ul>
|
||||
<li><a href="@Url.Action("Index", "Index")">About SMAPI</a></li>
|
||||
<li><a href="@Url.PlainAction("Index", "Index")">About SMAPI</a></li>
|
||||
<li><a href="https://stardewvalleywiki.com/Modding:Index">Modding docs</a></li>
|
||||
</ul>
|
||||
|
||||
<h4>Tools</h4>
|
||||
<ul>
|
||||
<li><a href="@Url.Action("Index", "Mods")">Mod compatibility</a></li>
|
||||
<li><a href="@Url.Action("Index", "LogParser")">Log parser</a></li>
|
||||
<li><a href="@Url.Action("Index", "JsonValidator")">JSON validator</a></li>
|
||||
<li><a href="@Url.PlainAction("Index", "Mods")">Mod compatibility</a></li>
|
||||
<li><a href="@Url.PlainAction("Index", "LogParser", values: null)">Log parser</a></li>
|
||||
<li><a href="@Url.PlainAction("Index", "JsonValidator", values: null)">JSON validator</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="content-column">
|
||||
|
|
Loading…
Reference in New Issue