cleanup GitHub and Pastebin paste services

This commit is contained in:
Kermina Awad 2020-06-05 22:09:08 -04:00
parent eb91eefc80
commit d69c492577
2 changed files with 8 additions and 9 deletions

View File

@ -49,7 +49,9 @@ public class GithubPasteService implements PasteService {
public URL getPostURL() {
try {
return new URL("https://api.github.com/gists");
//return new URL("http://jsonplaceholder.typicode.com/posts");
// the following can be used for testing purposes
// return new URL("http://jsonplaceholder.typicode.com/posts");
} catch (MalformedURLException e) {
return null; // should never hit here
}
@ -68,8 +70,6 @@ public class GithubPasteService implements PasteService {
rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
String pastieUrl = "";
//Pattern pastiePattern = this.getURLMatchingPattern();
StringBuilder responseString = new StringBuilder();
while ((line = rd.readLine()) != null) {

View File

@ -40,12 +40,11 @@ public class PastebinPasteService implements PasteService {
@Override
public String encodeData(String data) {
try {
String encData = URLEncoder.encode("api_dev_key", "UTF-8") + "=" + URLEncoder.encode("d61d68d31e8e0392b59b50b277411c71", "UTF-8");
encData += "&" + URLEncoder.encode("api_option", "UTF-8") + "=" + URLEncoder.encode("paste", "UTF-8");
encData += "&" + URLEncoder.encode("api_paste_code", "UTF-8") + "=" + URLEncoder.encode(data, "UTF-8");
encData += "&" + URLEncoder.encode("api_paste_private", "UTF-8") + "=" + URLEncoder.encode(this.isPrivate ? "1" : "0", "UTF-8");
encData += "&" + URLEncoder.encode("api_paste_format", "UTF-8") + "=" + URLEncoder.encode("yaml", "UTF-8");
return encData;
return URLEncoder.encode("api_dev_key", "UTF-8") + "=" + URLEncoder.encode("d61d68d31e8e0392b59b50b277411c71", "UTF-8") +
"&" + URLEncoder.encode("api_option", "UTF-8") + "=" + URLEncoder.encode("paste", "UTF-8") +
"&" + URLEncoder.encode("api_paste_code", "UTF-8") + "=" + URLEncoder.encode(data, "UTF-8") +
"&" + URLEncoder.encode("api_paste_private", "UTF-8") + "=" + URLEncoder.encode(this.isPrivate ? "1" : "0", "UTF-8") +
"&" + URLEncoder.encode("api_paste_format", "UTF-8") + "=" + URLEncoder.encode("yaml", "UTF-8");
} catch (UnsupportedEncodingException e) {
return ""; // should never hit here
}