getHttpUrlFromWebSocketUrl method

Uri getHttpUrlFromWebSocketUrl(
  1. String relayUrl
)

Implementation

Uri getHttpUrlFromWebSocketUrl(String relayUrl) {
  assert(
    relayUrl.startsWith("ws://") || relayUrl.startsWith("wss://"),
    "invalid relay url",
  );

  try {
    String removeWebsocketSign = relayUrl.replaceFirst("ws://", "http://");
    removeWebsocketSign =
        removeWebsocketSign.replaceFirst("wss://", "https://");
    return Uri.parse(removeWebsocketSign);
  } catch (e) {
    NostrClientUtils.log(
      "error while getting http url from websocket url: $relayUrl",
      e,
    );

    rethrow;
  }
}