Skip to content

Commit add3d95

Browse files
authored
Merge pull request #1759 from caminada/add-script-empty-context-fix
Return absolute path for scripts if contextPath is empty
2 parents afb250b + 90297cd commit add3d95

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/org/opensolaris/opengrok/web/Scripts.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public Iterator<Script> iterator() {
202202
* @return true if script was added; false otherwise
203203
*/
204204
public boolean addScript(String contextPath, String scriptName) {
205-
contextPath = contextPath == null || contextPath.isEmpty() ? "" : contextPath + "/";
205+
contextPath = contextPath == null || contextPath.isEmpty() ? "/" : contextPath + "/";
206206
if (SCRIPTS.containsKey(scriptName)) {
207207
this.addScript(
208208
// put the context path end append the script path

test/org/opensolaris/opengrok/web/ScriptsTest.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,16 @@
2222
*/
2323
package org.opensolaris.opengrok.web;
2424

25+
import static org.junit.Assert.assertEquals;
26+
import static org.junit.Assert.assertTrue;
27+
import static org.junit.Assert.fail;
28+
2529
import java.util.Map.Entry;
30+
2631
import org.junit.Before;
2732
import org.junit.Test;
2833
import org.opensolaris.opengrok.web.Scripts.Script;
2934

30-
import static org.junit.Assert.assertEquals;
31-
import static org.junit.Assert.assertTrue;
32-
import static org.junit.Assert.fail;
33-
3435
/**
3536
*
3637
* @author Krystof Tulinger
@@ -123,11 +124,11 @@ public void testLookup() {
123124
continue;
124125
}
125126
assertTrue(scripts.toHtml() + " must contain <script type=\"text/javascript\""
126-
+ " src=\"" + s.getValue().getScriptData() + "\""
127+
+ " src=\"/" + s.getValue().getScriptData() + "\""
127128
+ " data-priority=\"" + s.getValue().getPriority() + "\"></script>",
128129
scripts.toHtml()
129130
.contains("<script type=\"text/javascript\""
130-
+ " src=\"" + s.getValue().getScriptData() + "\""
131+
+ " src=\"/" + s.getValue().getScriptData() + "\""
131132
+ " data-priority=\"" + s.getValue().getPriority() + "\"></script>"));
132133
}
133134
}

0 commit comments

Comments
 (0)