mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
trim trailing slashes from path substitutions
This commit is contained in:
parent
65903c56de
commit
57c92fa948
@ -96,10 +96,36 @@ namespace MediaBrowser.Server.Implementations.Configuration
|
|||||||
|
|
||||||
ValidateItemByNamePath(newConfig);
|
ValidateItemByNamePath(newConfig);
|
||||||
ValidateTranscodingTempPath(newConfig);
|
ValidateTranscodingTempPath(newConfig);
|
||||||
|
ValidatePathSubstitutions(newConfig);
|
||||||
|
|
||||||
base.ReplaceConfiguration(newConfiguration);
|
base.ReplaceConfiguration(newConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ValidatePathSubstitutions(ServerConfiguration newConfig)
|
||||||
|
{
|
||||||
|
foreach (var map in newConfig.PathSubstitutions)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(map.From) || string.IsNullOrWhiteSpace(map.To))
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Invalid path substitution");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!map.From.EndsWith(":\\") && !map.From.EndsWith(":/"))
|
||||||
|
{
|
||||||
|
map.From = map.From.TrimEnd('/').TrimEnd('\\');
|
||||||
|
}
|
||||||
|
if (!map.To.EndsWith(":\\") && !map.To.EndsWith(":/"))
|
||||||
|
{
|
||||||
|
map.To = map.To.TrimEnd('/').TrimEnd('\\');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(map.From) || string.IsNullOrWhiteSpace(map.To))
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Invalid path substitution");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Replaces the item by name path.
|
/// Replaces the item by name path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user