Files
5chan/src/utils/formatState.js
T

27 lines
587 B
JavaScript
Raw Normal View History

2023-04-23 11:46:14 +02:00
function formatState(str) {
2023-05-07 16:50:05 +02:00
if (!str) {
return null;
}
const formattedWords = str
.replace(/-/g, " ")
.split(" ")
.map((word, index) => {
word = word.toLowerCase();
if (word === "ipfs" || word === "ipns") {
return word.toUpperCase();
} else if (index === 0) {
return word.charAt(0).toUpperCase() + word.slice(1);
} else {
return word;
}
});
if (formattedWords.includes("Failed")) {
return formattedWords.join(" ") + ".";
}
return formattedWords.join(" ") + "...";
2023-04-23 11:46:14 +02:00
}
export default formatState;