Skip to content

Fixes what was broken due to #1358 issue fix. #1392

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

Merged
merged 2 commits into from
Nov 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/main/java/com/gitblit/wicket/MarkupProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,22 @@ public Rendering render(WikiLinkNode node) {

@Override
public Rendering render(ExpLinkNode node, String text) {
// Relative file-like MD links needs to be re-mapped to be relative to
// repository name so that they display correctly sub-folder files
// Absolute links must be left un-touched.

// Note: The absolute lack of comments in ExpLinkNode is... well...
// I assume, that getRelativePath is handling "file like" links
// like "/xx/tt" or "../somefolder". What needs to be captured
// is a full URL link. The easiest is to ask java to parse URL
// and let it fail. Shame java.net.URL has no method to validate URL without
// throwing.
try {
new java.net.URL(node.url);
// This is URL, fallback to superclass.
return super.render(node,text);
} catch (java.net.MalformedURLException ignored) {};
// repository-relative link
String path = doc.getRelativePath(node.url);
String url = getWicketUrl(DocPage.class, repositoryName, commitId, path);
return new Rendering(url, text);
Expand Down