From 16e4747d3cb2c2a53a6bef554bca306d8594a080 Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Fri, 14 Sep 2012 17:51:04 -0400 Subject: [PATCH] Mostly complete blob view line links feature, DOM offset bug remains (issue 130) --- src/com/gitblit/utils/FileUtils.java | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/com/gitblit/utils/FileUtils.java b/src/com/gitblit/utils/FileUtils.java index c291da6..cba88d0 100644 --- a/src/com/gitblit/utils/FileUtils.java +++ b/src/com/gitblit/utils/FileUtils.java @@ -226,7 +226,10 @@ public static String getRelativePath(File basePath, File path) { File exactBase = getExactFile(basePath); File exactPath = getExactFile(path); - if (exactPath.getPath().startsWith(exactBase.getPath())) { + if (path.getAbsolutePath().startsWith(basePath.getAbsolutePath())) { + // absolute base-path match + return StringUtils.getRelativePath(basePath.getAbsolutePath(), path.getAbsolutePath()); + } else if (exactPath.getPath().startsWith(exactBase.getPath())) { // canonical base-path match return StringUtils.getRelativePath(exactBase.getPath(), exactPath.getPath()); } else if (exactPath.getPath().startsWith(basePath.getAbsolutePath())) { @@ -235,9 +238,6 @@ } else if (path.getAbsolutePath().startsWith(exactBase.getPath())) { // mixed path match return StringUtils.getRelativePath(exactBase.getPath(), path.getAbsolutePath()); - } else if (path.getAbsolutePath().startsWith(basePath.getAbsolutePath())) { - // absolute base-path match - return StringUtils.getRelativePath(basePath.getAbsolutePath(), path.getAbsolutePath()); } // no relative relationship return null; -- Gitblit v1.9.1