fix #569 : Site path is not displayed on search result page
This commit is contained in:
parent
526ff5e264
commit
8f5100fd36
2 changed files with 17 additions and 11 deletions
|
@ -480,7 +480,8 @@ public class ViewHelper {
|
|||
}
|
||||
|
||||
public Object getSitePath(final Map<String, Object> docMap) {
|
||||
final Object urlLink = docMap.get("urlLink");
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
final Object urlLink = docMap.get(fessConfig.getResponseFieldUrlLink());
|
||||
if (urlLink != null) {
|
||||
final String returnUrl;
|
||||
final String url = urlLink.toString();
|
||||
|
|
|
@ -18,7 +18,9 @@ package org.codelibs.fess.helper;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.codelibs.fess.mylasta.direction.FessConfig;
|
||||
import org.codelibs.fess.unit.UnitFessTestCase;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
|
||||
public class ViewHelperTest extends UnitFessTestCase {
|
||||
public ViewHelper viewHelper;
|
||||
|
@ -103,54 +105,57 @@ public class ViewHelperTest extends UnitFessTestCase {
|
|||
String sitePath;
|
||||
final Map<String, Object> docMap = new HashMap<>();
|
||||
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
final String fieldName = fessConfig.getResponseFieldUrlLink();
|
||||
|
||||
urlLink = "http://www.google.com";
|
||||
sitePath = "www.google.com";
|
||||
docMap.put("urlLink", urlLink);
|
||||
docMap.put(fieldName, urlLink);
|
||||
assertEquals(sitePath, viewHelper.getSitePath(docMap));
|
||||
|
||||
urlLink = "https://www.jp.websecurity.symantec.com/";
|
||||
sitePath = "www.jp.websecurity.symantec.com/";
|
||||
docMap.put("urlLink", urlLink);
|
||||
docMap.put(fieldName, urlLink);
|
||||
assertEquals(sitePath, viewHelper.getSitePath(docMap));
|
||||
|
||||
urlLink = "http://www.qwerty.jp";
|
||||
sitePath = "www.qwerty.jp";
|
||||
docMap.put("urlLink", urlLink);
|
||||
docMap.put(fieldName, urlLink);
|
||||
assertEquals(sitePath, viewHelper.getSitePath(docMap));
|
||||
|
||||
urlLink = "://www.qwerty.jp";
|
||||
sitePath = "www.qwerty.jp";
|
||||
docMap.put("urlLink", urlLink);
|
||||
docMap.put(fieldName, urlLink);
|
||||
assertEquals(sitePath, viewHelper.getSitePath(docMap));
|
||||
|
||||
urlLink = "www.google.com";
|
||||
sitePath = "www.google.com";
|
||||
docMap.put("urlLink", urlLink);
|
||||
docMap.put(fieldName, urlLink);
|
||||
assertEquals(sitePath, viewHelper.getSitePath(docMap));
|
||||
|
||||
urlLink = "smb://123.45.678.91/share1";
|
||||
sitePath = "123.45.678.91/share1";
|
||||
docMap.put("urlLink", urlLink);
|
||||
docMap.put(fieldName, urlLink);
|
||||
assertEquals(sitePath, viewHelper.getSitePath(docMap));
|
||||
|
||||
urlLink = "file:/home/user/";
|
||||
sitePath = "/home/user/";
|
||||
docMap.put("urlLink", urlLink);
|
||||
docMap.put(fieldName, urlLink);
|
||||
assertEquals(sitePath, viewHelper.getSitePath(docMap));
|
||||
|
||||
urlLink = "file://home/user/";
|
||||
sitePath = "/home/user/";
|
||||
docMap.put("urlLink", urlLink);
|
||||
docMap.put(fieldName, urlLink);
|
||||
assertEquals(sitePath, viewHelper.getSitePath(docMap));
|
||||
|
||||
urlLink = "file://c:/home/user/";
|
||||
sitePath = "c:/home/user/";
|
||||
docMap.put("urlLink", urlLink);
|
||||
docMap.put(fieldName, urlLink);
|
||||
assertEquals(sitePath, viewHelper.getSitePath(docMap));
|
||||
|
||||
urlLink = "file://1.2.3.4/user/";
|
||||
sitePath = "1.2.3.4/user/";
|
||||
docMap.put("urlLink", urlLink);
|
||||
docMap.put(fieldName, urlLink);
|
||||
assertEquals(sitePath, viewHelper.getSitePath(docMap));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue