diff options
author | alx | 2019-03-16 23:56:27 +0300 |
---|---|---|
committer | alx | 2019-03-16 23:56:27 +0300 |
commit | 06105f76dbfa3b65e63ed06f9c4d5107bd49ed88 (patch) | |
tree | 5702c01cec9688039d891f4a711878706101c1c5 /src/main/java/ru/sape | |
parent | 3ea4cd1942fa4e763034da11c5fa429407b67829 (diff) | |
parent | a49105285d0d7719d7f222a507af2d5ac5b4bdb1 (diff) |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src/main/java/ru/sape')
-rw-r--r-- | src/main/java/ru/sape/Sape.java | 4 | ||||
-rw-r--r-- | src/main/java/ru/sape/SapePageLinks.java | 15 |
2 files changed, 11 insertions, 8 deletions
diff --git a/src/main/java/ru/sape/Sape.java b/src/main/java/ru/sape/Sape.java index 38577c45..a94bcc62 100644 --- a/src/main/java/ru/sape/Sape.java +++ b/src/main/java/ru/sape/Sape.java @@ -3,6 +3,8 @@ */ package ru.sape; +import java.net.URI; + public class Sape { private final String sapeUser; @@ -17,7 +19,7 @@ public class Sape { } public boolean debug = false; - public SapePageLinks getPageLinks(String requestUri, String cookie) { + public SapePageLinks getPageLinks(URI requestUri, String cookie) { return new SapePageLinks(sapePageLinkConnection, sapeUser, requestUri, cookie, debug); } } diff --git a/src/main/java/ru/sape/SapePageLinks.java b/src/main/java/ru/sape/SapePageLinks.java index e89b4e71..77715aea 100644 --- a/src/main/java/ru/sape/SapePageLinks.java +++ b/src/main/java/ru/sape/SapePageLinks.java @@ -1,17 +1,18 @@ package ru.sape; +import org.apache.commons.lang3.StringUtils; + +import java.net.URI; import java.util.*; public class SapePageLinks { private boolean showCode; - public SapePageLinks(SapeConnection sapeConnection, String sapeUser, String requestUri, String sapeCookie) { - this(sapeConnection, sapeUser, requestUri, sapeCookie, false); - } - @SuppressWarnings("unchecked") - public SapePageLinks(SapeConnection sapeConnection, String sapeUser, String requestUri, String sapeCookie, boolean showCode) { + public SapePageLinks(SapeConnection sapeConnection, String sapeUser, URI request, String sapeCookie, boolean showCode) { + String req = StringUtils.isNotEmpty(request.getQuery()) ? request.getPath() + "?" + request.getQuery() + : request.getPath(); if (sapeUser.equals(sapeCookie)) { showCode = true; } @@ -22,8 +23,8 @@ public class SapePageLinks { linkDelimiter = (String) data.get("__sape_delimiter__"); } - if (data.containsKey(requestUri)) { - pageLinks = new ArrayList<>(((Map<Object, String>) data.get(requestUri)).values()); + if (data.containsKey(req)) { + pageLinks = new ArrayList<>(((Map<Object, String>) data.get(req)).values()); } if (data.containsKey("__sape_new_url__")) { |