Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix path in editPost URL for Windows #333

Merged
merged 1 commit into from
Mar 28, 2021

Conversation

Syphdias
Copy link
Contributor

.File.Path is OS dependant and uses \ as directory separator. This leads to
cases where posts get the wrong URL, if in a sub folder, e.g.
content/posts/folder\post.md.

One idea was to replace \ with / this however breaks valid files (on Unix
systems) which include \ in the file name.
According to the docs path.Join is OS
unaware and converts to a Unix-like path.

Note: All path elements on Windows are converted to slash ('/') separators.

PS: It looks like hugo also uses this internally to build URLs.
PPS: Solution was discussed in #278.

`.File.Path` is OS dependant and uses `\` as directory separator. This leads to
cases where posts get the wrong URL, if in a sub folder, e.g.
`content/posts/folder\post.md`.

One idea was to replace `\` with `/` this however breaks valid files (on Unix
systems) which include `\` in the file name.
According to the docs [`path.Join`](layouts/partials/edit_post.html) is OS
unaware and converts to a Unix-like path.

> Note: All path elements on Windows are converted to slash ('/') separators.

PS: It looks like hugo also uses this internally to build URLs.
PPS: Solution was discussed in adityatelange#278.
@sonarcloud
Copy link

sonarcloud bot commented Mar 28, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@adityatelange adityatelange merged commit 54744ba into adityatelange:master Mar 28, 2021
@Syphdias Syphdias deleted the edit-post-link branch March 28, 2021 19:36
mbrukman pushed a commit to mbrukman/hugo-PaperMod that referenced this pull request Apr 4, 2021
kylethedeveloper pushed a commit to kylethedeveloper/hugo-PaperMod that referenced this pull request Feb 21, 2023
kylethedeveloper pushed a commit to kylethedeveloper/hugo-PaperMod that referenced this pull request Feb 21, 2023
`.File.Path` is OS dependant and uses `\` as directory separator. This leads to
cases where posts get the wrong URL, if in a sub folder, e.g.
`content/posts/folder\post.md`.

One idea was to replace `\` with `/` this however breaks valid files (on Unix
systems) which include `\` in the file name.
According to the docs [`path.Join`](layouts/partials/edit_post.html) is OS
unaware and converts to a Unix-like path.

> Note: All path elements on Windows are converted to slash ('/') separators.

PS: It looks like hugo also uses this internally to build URLs.
PPS: Solution was discussed in adityatelange#278.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants