Fixing confusing wss -> https case

This commit is contained in:
Joakim Erdfelt 2017-05-30 12:09:34 -07:00
parent c9c284f432
commit ae496051de
2 changed files with 11 additions and 11 deletions

View File

@ -45,19 +45,19 @@ public final class WSURI
if ("http".equalsIgnoreCase(wsScheme) || "https".equalsIgnoreCase(wsScheme))
{
// leave alone
return new URI(inputUri.toString());
return inputUri;
}
if ("ws".equalsIgnoreCase(wsScheme))
{
// convert to http
return new URI("http"+inputUri.toString().substring(2));
return new URI("http" + inputUri.toString().substring(wsScheme.length()));
}
if ("wss".equalsIgnoreCase(wsScheme))
{
// convert to https
return new URI("http"+inputUri.toString().substring(2));
return new URI("https" + inputUri.toString().substring(wsScheme.length()));
}
throw new URISyntaxException(inputUri.toString(),"Unrecognized WebSocket scheme");
@ -126,13 +126,13 @@ public final class WSURI
if ("http".equalsIgnoreCase(httpScheme))
{
// convert to ws
return new URI("ws"+inputUri.toString().substring(4));
return new URI("ws" + inputUri.toString().substring(httpScheme.length()));
}
if ("https".equalsIgnoreCase(httpScheme))
{
// convert to wss
return new URI("wss"+inputUri.toString().substring(5));
return new URI("wss" + inputUri.toString().substring(httpScheme.length()));
}
throw new URISyntaxException(inputUri.toString(),"Unrecognized HTTP scheme");