Pretty URLs break “Edit this page” links
- Dominant language
- HTML
- Stars
- 17
- Forks
- 23
- Avg merge
- 14h 48m
- Merged PRs (30d)
- 1
Description
## Expected Behavior
While reporting https://github.com/dita-ot/docs/issues/607, @stefan-jung discovered:
> I tried to modify the following topic with the **Edit this page** button:
> https://www.dita-ot.org/dev/topics/plugin-messages#ariaid-title1
— but it didn't work.
## Actual Behavior
[oXygen XML Web Author](https://www.oxygenxml.com/xml_web_author.html) returns an error that it can't find the resource to edit.
Looks like a side-effect of Netlify’s post-processing for [pretty URLs](https://docs.netlify.com/site-deploys/post-processing/#post-processing-features).
At first glance, it looked like the trailing fragment identifier `#ariaid-title1` that Algolia adds when you follow links in the site search results could be to blame.
But stripping that isn’t enough. Web Author also doesn’t find the topic under [topics/plugin-messages](https://www.dita-ot.org/dev/topics/plugin-messages).
It seems Web Author relies on the `.html` file name extension to locate the corresponding `.dita` source file.
If you manually edit the URL in your browser to [topics/plugin-messages.html](https://www.dita-ot.org/dev/topics/plugin-messages.html) and then click **Edit this page**, it works.
## Possible Solution
We’d probably need to edit the logic in the `parse()` function on [lines 55–56 of the EditController.js](https://github.com/dita-ot/website/blob/master/_js/lib/EditController.js#L55-L56) file.
Not sure if there's a concise (and resilient) way of refactoring that that would work with the pretty URL syntax. 🤔
One thing that comes to mind would be walking the URL backward from the end to find the last slash `/`, then using the final sequence of letters, dashes, or underscores that construct the root filename, ignoring any trailing fragment identifiers.
— but there may be a better way.
@raducoravu, @jelovirt Any suggestions?
Contributor guide
Assessment
This issue has not been assessed yet.