Display search property alongside host in relay name (#452)
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { splitByUrl, magnetURIDecode } from "./Util";
|
||||
import { splitByUrl, magnetURIDecode, getRelayName } from "./Util";
|
||||
|
||||
describe("splitByUrl", () => {
|
||||
it("should split a string by URLs", () => {
|
||||
@ -56,3 +56,22 @@ describe("magnet", () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getRelayName", () => {
|
||||
it("should return relay name", () => {
|
||||
const url = "wss://relay.snort.social/";
|
||||
const output = getRelayName(url);
|
||||
expect(output).toEqual("relay.snort.social");
|
||||
});
|
||||
it("should return relay name with search property", () => {
|
||||
const url = "wss://relay.example1.com/?lang=en";
|
||||
const output = getRelayName(url);
|
||||
expect(output).toEqual("relay.example1.com?lang=en");
|
||||
});
|
||||
it("should return relay name without pathname", () => {
|
||||
const url =
|
||||
"wss://relay.example2.com/npub1sn0rtcjcf543gj4wsg7fa59s700d5ztys5ctj0g69g2x6802npjqhjjtws?broadcast=true";
|
||||
const output = getRelayName(url);
|
||||
expect(output).toEqual("relay.example2.com?broadcast=true");
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user