Issue #1568 handle query strings with encoded characters

This commit is contained in:
Greg Wilkins 2017-05-24 23:03:22 +02:00
parent 78280d0595
commit 50500ac99d
1 changed files with 10 additions and 12 deletions

View File

@ -45,7 +45,7 @@ public final class WSURI
if ("http".equalsIgnoreCase(wsScheme) || "https".equalsIgnoreCase(wsScheme))
{
// leave alone
return inputUri; // TODO should this be cloned?
return new URI(inputUri.toString());
}
if ("ws".equalsIgnoreCase(wsScheme))
@ -117,26 +117,24 @@ public final class WSURI
{
Objects.requireNonNull(inputUri,"Input URI must not be null");
String httpScheme = inputUri.getScheme();
String wsScheme = null;
if ("ws".equalsIgnoreCase(httpScheme) || "wss".equalsIgnoreCase(httpScheme))
{
// keep as-is
wsScheme = httpScheme;
return new URI(inputUri.toString());
}
else if ("http".equalsIgnoreCase(httpScheme))
if ("http".equalsIgnoreCase(httpScheme))
{
// convert to ws
wsScheme = "ws";
return new URI("ws"+inputUri.toString().substring(4));
}
else if ("https".equalsIgnoreCase(httpScheme))
if ("https".equalsIgnoreCase(httpScheme))
{
// convert to wss
wsScheme = "wss";
return new URI("wss"+inputUri.toString().substring(5));
}
else
{
throw new URISyntaxException(inputUri.toString(),"Unrecognized HTTP scheme");
}
return new URI(wsScheme,inputUri.getUserInfo(),inputUri.getHost(),inputUri.getPort(),inputUri.getPath(),inputUri.getQuery(),inputUri.getFragment());
throw new URISyntaxException(inputUri.toString(),"Unrecognized HTTP scheme");
}
}