diff --git a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/impl/AbstractWebSocket.java b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/impl/AbstractWebSocket.java
index bbe4ac7493..05cc7ac4be 100644
--- a/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/impl/AbstractWebSocket.java
+++ b/smack-websocket/src/main/java/org/jivesoftware/smack/websocket/impl/AbstractWebSocket.java
@@ -95,7 +95,9 @@ protected final void onIncomingWebSocketElement(String element) {
static String getStreamFromOpenElement(String openElement) {
String streamElement = openElement.replaceFirst("\\A\\s*\\z", " xmlns:stream='http://etherx.jabber.org/streams'>");
+ .replaceFirst("/>\\s*\\z", " xmlns:stream='http://etherx.jabber.org/streams'>")
+ .replaceFirst(">\\s*\\z", " xmlns:stream='http://etherx.jabber.org/streams'>");
+
return streamElement;
}
diff --git a/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/impl/AbstractWebSocketTest.java b/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/impl/AbstractWebSocketTest.java
index 23f2746165..5280efe7b9 100644
--- a/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/impl/AbstractWebSocketTest.java
+++ b/smack-websocket/src/test/java/org/jivesoftware/smack/websocket/impl/AbstractWebSocketTest.java
@@ -24,18 +24,20 @@
public final class AbstractWebSocketTest {
private static final String OPEN_ELEMENT = "";
+ private static final String OPEN_ELEMENT_EXPANDED = "";
private static final String OPEN_STREAM = "";
private static final String CLOSE_ELEMENT = "";
@Test
public void getStreamFromOpenElementTest() {
- String generatedOpenStream = AbstractWebSocket.getStreamFromOpenElement(OPEN_ELEMENT);
- assertEquals(generatedOpenStream, OPEN_STREAM);
+ assertEquals(OPEN_STREAM, AbstractWebSocket.getStreamFromOpenElement(OPEN_ELEMENT));
+ assertEquals(OPEN_STREAM, AbstractWebSocket.getStreamFromOpenElement(OPEN_ELEMENT_EXPANDED));
}
@Test
public void isOpenElementTest() {
assertTrue(AbstractWebSocket.isOpenElement(OPEN_ELEMENT));
+ assertTrue(AbstractWebSocket.isOpenElement(OPEN_ELEMENT_EXPANDED));
assertFalse(AbstractWebSocket.isOpenElement(OPEN_STREAM));
}