@hiveposh/so-many-frontends
Advanced tools
Comparing version 0.0.3 to 0.0.4
11
index.js
@@ -26,3 +26,8 @@ const hiveDomains = [ | ||
for (const i in hiveDomains) { | ||
if (url.includes(hiveDomains[i])) { | ||
const parsedUrl = new URL(url); | ||
if ( | ||
parsedUrl.host == hiveDomains[i] || | ||
parsedUrl.host == "www." + hiveDomains[i] || | ||
parsedUrl.host == "beta." + hiveDomains[i] | ||
) { | ||
return true; | ||
@@ -47,6 +52,6 @@ } | ||
const slug = parsedUrl.pathname.split("@")[1]; | ||
let author, permlink; | ||
if (slug) { | ||
if (slug && slug.includes("/")) { | ||
author = slug.split("/")[0]; | ||
@@ -53,0 +58,0 @@ permlink = slug.split("/")[1]; |
{ | ||
"name": "@hiveposh/so-many-frontends", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "JS module for listing Hive front ends", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
46
tests.js
@@ -12,4 +12,16 @@ const test = require("node:test"); | ||
test("isHiveUrl happy path 2", (t) => { | ||
assert.strictEqual( | ||
isHiveUrl("https://beta.peakd.com/@manuphotos/muogh"), | ||
true | ||
); | ||
}); | ||
test("isHiveUrl negative path", (t) => { | ||
assert.strictEqual(isHiveUrl("https://www.google.io/what"), false); | ||
assert.strictEqual( | ||
isHiveUrl( | ||
"https://sunbowmarvelarchive.blogspot.com/2023/01/the-mystery-of-time-challengers-1991.html" | ||
), | ||
false | ||
); | ||
}); | ||
@@ -32,6 +44,7 @@ | ||
test("parseHiveUrl 3Speak", (t) => { | ||
assert.deepEqual( | ||
parseHiveUrl("https://3speak.tv/watch?v=itstman/jmicmsyo"), | ||
{ domain: "3speak.tv", author: "itstman", permlink: "jmicmsyo" } | ||
); | ||
assert.deepEqual(parseHiveUrl("https://3speak.tv/watch?v=itstman/jmicmsyo"), { | ||
domain: "3speak.tv", | ||
author: "itstman", | ||
permlink: "jmicmsyo", | ||
}); | ||
}); | ||
@@ -53,3 +66,2 @@ | ||
test("parseHiveUrl peakd.com with query params", (t) => { | ||
@@ -63,4 +75,3 @@ assert.deepEqual( | ||
domain: "peakd.com", | ||
permlink: | ||
"happy-new-year-or-my-first-hpud-post-or", | ||
permlink: "happy-new-year-or-my-first-hpud-post-or", | ||
} | ||
@@ -72,10 +83,7 @@ ); | ||
assert.deepEqual( | ||
parseHiveUrl( | ||
"https://peakd.com/hive-124452/@blackdaisyft/happy.new.year" | ||
), | ||
parseHiveUrl("https://peakd.com/hive-124452/@blackdaisyft/happy.new.year"), | ||
{ | ||
author: "blackdaisyft", | ||
domain: "peakd.com", | ||
permlink: | ||
"happynewyear", | ||
permlink: "happynewyear", | ||
} | ||
@@ -96,3 +104,11 @@ ); | ||
} | ||
) | ||
}); | ||
); | ||
}); | ||
test("parseHiveUrl peakd.com no permlink", (t) => { | ||
assert.deepEqual(parseHiveUrl("https://peakd.com/@trending"), { | ||
author: undefined, | ||
domain: "peakd.com", | ||
permlink: undefined, | ||
}); | ||
}); |
6904
156