From ed1d38ef2ee487cb260ddfc10179ba475efc1dea Mon Sep 17 00:00:00 2001 From: bwalding Date: Mon, 10 Mar 2003 14:18:41 +0000 Subject: [PATCH] o MAVEN-320: Make it handle slightly less conformant hrefs. Feels a bit dirty to me. git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@113096 13f79535-47bb-0310-9956-ffa450edef68 --- xdoc/src/main/org/apache/maven/NavBean.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/xdoc/src/main/org/apache/maven/NavBean.java b/xdoc/src/main/org/apache/maven/NavBean.java index 5fcf9b52..d7484a57 100644 --- a/xdoc/src/main/org/apache/maven/NavBean.java +++ b/xdoc/src/main/org/apache/maven/NavBean.java @@ -64,7 +64,7 @@ import org.dom4j.tree.DefaultElement; /** * @author Ben Walding - * @version $Id: NavBean.java,v 1.3 2003/02/18 14:21:35 bwalding Exp $ + * @version $Id: NavBean.java,v 1.4 2003/03/10 14:18:41 bwalding Exp $ */ public class NavBean { @@ -128,8 +128,17 @@ public class NavBean return false; } - String xpath = ".//item[@href='" + location + "']"; + //System.out.println(elem.asXML()); + String xpath; + if (location.startsWith("/") || location.startsWith(".")) { + xpath = ".//item[@href='" + location + "']"; + } else { + xpath = ".//item[@href='/" + location + "']"; + + } + + List l = elem.selectNodes(xpath); if (l.size() != 0) @@ -167,6 +176,9 @@ public class NavBean */ public void setLocation(String location) { + if (!location.startsWith("/")) + location = "/" + location; + this.location = location; }