X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=inline;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ftemplate%2FRequestChangeFilter.java;h=d004dfcedaee71a8d54334590afef3587a752ee3;hb=9b102d5ff09775e3867ad8709f22baf0ad608d30;hp=a0d80aff57db85b764ccf1996d8cf605a26e0fd4;hpb=0df5e91852f737d760c5a9f54c5667309fbadcc2;p=Sone.git
diff --git a/src/main/java/net/pterodactylus/sone/template/RequestChangeFilter.java b/src/main/java/net/pterodactylus/sone/template/RequestChangeFilter.java
index a0d80af..d004dfc 100644
--- a/src/main/java/net/pterodactylus/sone/template/RequestChangeFilter.java
+++ b/src/main/java/net/pterodactylus/sone/template/RequestChangeFilter.java
@@ -1,5 +1,5 @@
/*
- * Sone - RequestChangeFilter.java - Copyright © 2010 David Roden
+ * Sone - RequestChangeFilter.java - Copyright © 2010â2019 David Roden
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -33,10 +33,7 @@ import net.pterodactylus.util.template.TemplateContext;
/**
* This filter expects a {@link FreenetRequest} as input and outputs a
* {@link URI} that is modified by the parameters. The name of the parameter is
- * handed in as ânameâ, the value may either be stored in âvalueâ, or in a
- * template variable whose key is stored in âkeyâ.
- *
- * @author David âBombeâ Roden
+ * handed in as ânameâ, the new value is stored in âvalueâ.
*/
public class RequestChangeFilter implements Filter {
@@ -44,26 +41,12 @@ public class RequestChangeFilter implements Filter {
* {@inheritDoc}
*/
@Override
- public Object format(TemplateContext templateContext, Object data, Map parameters) {
+ public Object format(TemplateContext templateContext, Object data, Map parameters) {
FreenetRequest request = (FreenetRequest) data;
- String name = parameters.get("name");
- String nameKey = parameters.get("nameKey");
- if (nameKey != null) {
- name = String.valueOf(templateContext.get(nameKey));
- }
- String key = parameters.get("key");
- String value = null;
- if (key != null) {
- value = String.valueOf(templateContext.get(key));
- }
- if (value == null) {
- value = parameters.get("value");
- }
- if (value == null) {
- return request.getUri();
- }
+ String name = String.valueOf(parameters.get("name"));
+ String value = String.valueOf(parameters.get("value"));
- Map values = new HashMap();
+ Map values = new HashMap<>();
Collection parameterNames = request.getHttpRequest().getParameterNames();
for (String parameterName : parameterNames) {
values.put(parameterName, request.getHttpRequest().getParam(parameterName));
@@ -83,8 +66,7 @@ public class RequestChangeFilter implements Filter {
if (questionMark == -1) {
questionMark = oldUri.length();
}
- URI u = new URI(oldUri.substring(0, questionMark) + query.toString());
- return u;
+ return new URI(oldUri.substring(0, questionMark) + query.toString());
} catch (UnsupportedEncodingException uee1) {
/* UTF-8 not supported? I donât think so. */
} catch (URISyntaxException use1) {