fix state strings bug

This commit is contained in:
Esteban Abaroa
2023-05-10 23:13:24 +00:00
parent 0e77779f1e
commit 7849201a2b
3 changed files with 13 additions and 4 deletions
+1 -1
View File
@@ -8,7 +8,7 @@
"@babel/plugin-transform-react-jsx": "7.21.0",
"@capacitor/android": "3.6.0",
"@capacitor/core": "3.6.0",
"@plebbit/plebbit-react-hooks": "https://github.com/plebbit/plebbit-react-hooks.git#e602eda8080f2b3449388c2d5868d6e6da60c8f6",
"@plebbit/plebbit-react-hooks": "https://github.com/plebbit/plebbit-react-hooks.git#36755ca6b159da9f07591d008082a93a2434d147",
"@testing-library/dom": "9.0.1",
"@testing-library/jest-dom": "5.14.1",
"@testing-library/react": "14.0.0",
+10 -1
View File
@@ -21,10 +21,19 @@ const useStateString = (clients) => {
}
}
const getClientHost = (clientUrl) => {
try {
return new URL(clientUrl).hostname || clientUrl
}
catch (e) {
return clientUrl
}
}
let stateString = ''
for (const state in states) {
const clientUrls = states[state]
const clientHosts = clientUrls.filter(isValidUrl).map(clientUrl => new URL(clientUrl).hostname)
const clientHosts = clientUrls.filter(isValidUrl).map(clientUrl => getClientHost(clientUrl))
// if there are no valid hosts, skip this state
if (clientHosts.length === 0) {
+2 -2
View File
@@ -2668,9 +2668,9 @@
dependencies:
debug "4.3.3"
"@plebbit/plebbit-react-hooks@https://github.com/plebbit/plebbit-react-hooks.git#e602eda8080f2b3449388c2d5868d6e6da60c8f6":
"@plebbit/plebbit-react-hooks@https://github.com/plebbit/plebbit-react-hooks.git#36755ca6b159da9f07591d008082a93a2434d147":
version "0.0.1"
resolved "https://github.com/plebbit/plebbit-react-hooks.git#e602eda8080f2b3449388c2d5868d6e6da60c8f6"
resolved "https://github.com/plebbit/plebbit-react-hooks.git#36755ca6b159da9f07591d008082a93a2434d147"
dependencies:
"@plebbit/plebbit-js" "https://github.com/plebbit/plebbit-js.git#bcf4ec7ba024fdd7dc0bb2fab76c27c93597dd50"
"@plebbit/plebbit-logger" "https://github.com/plebbit/plebbit-logger.git"