Closed orinem closed 2 years ago
Thanks @orinem - excellent catch. I've also adjusted the constructor to ContentRoute
as follows:
/// <summary>
/// Create a new route object.
/// </summary>
/// <param name="path">The pattern against which the raw URL should be matched.</param>
/// <param name="isDirectory">Indicates whether or not the path specifies a directory. If so, any matching URL will be handled by the specified handler.</param>
/// <param name="guid">Globally-unique identifier.</param>
/// <param name="metadata">User-supplied metadata.</param>
public ContentRoute(string path, bool isDirectory, string guid = null, object metadata = null)
{
if (String.IsNullOrEmpty(path)) throw new ArgumentNullException(nameof(path));
Path = path.ToLower();
IsDirectory = isDirectory;
if (IsDirectory) if (!Path.EndsWith("/")) Path += "/";
if (!String.IsNullOrEmpty(guid)) GUID = guid;
if (metadata != null) Metadata = metadata;
}
I will incorporate your fix using the dirPath
variable. Will be in the next release. Thanks so much!
Match() adds a trailing '/' to all incoming paths. This fails to match a route for an individual file (which shouldn't end with a '/').
The simple solution is to only append a '/' if comparing against a route that is a directory, or as below, create a separate 'dirPath' variable with the trailing '/' to be used when comparing routes that are directories.