Statiq.Framework icon indicating copy to clipboard operation
Statiq.Framework copied to clipboard

Configuration for removing multiple dashes from file name

Open SIkebe opened this issue 5 years ago • 1 comments

Statiq.Common.NormalizedPath.OptimizeFileName() removes multiple dashes by default. https://github.com/statiqdev/Statiq.Framework/blob/e0e0bc5ba49fb657ebf5b25e69fd1da8b7a6aed7/src/core/Statiq.Common/IO/NormalizedPath.cs#L979-L980

Currently, there is no way to configure this behavior. And I saw some links broken in .NET Foundation site. Is this by design? From a security perspective?

SIkebe avatar Jun 13 '20 15:06 SIkebe

Not really by design, more just a best practice I've noticed (though I don't really have anything concrete to base that on - there's no real "standard" around friendly URLs that I'm aware of).

Generally links should be generated using Statiq helpers like Document.GetLink() and @Html.DocumentLink(document) so that the link follows whatever logic is being used to determine output location. Otherwise hand-coded /foo/bar style paths tend to break in other subtle ways like if a web server requires extensions or not.

If we were to add a few toggles to the way file names are optimized (and thus the output file/link for documents) what would they be? Collapsing dashes (or not) could be one, any others you can think of?

daveaglick avatar Jun 24 '20 23:06 daveaglick