mirror of https://github.com/MaxLeiter/Drift
client: mine page fixes, remove lodash.debounce
parent
1369bdf996
commit
fe589d63d8
@ -1,29 +1,35 @@
|
||||
const replaceLastInString = (
|
||||
string: string,
|
||||
search: string,
|
||||
replace: string
|
||||
string: string,
|
||||
search: string,
|
||||
replace: string
|
||||
): string => {
|
||||
const index = string.lastIndexOf(search);
|
||||
if (index === -1) {
|
||||
return string;
|
||||
}
|
||||
return string.substring(0, index) + replace + string.substring(index + search.length);
|
||||
const index = string.lastIndexOf(search)
|
||||
if (index === -1) {
|
||||
return string
|
||||
}
|
||||
return (
|
||||
string.substring(0, index) +
|
||||
replace +
|
||||
string.substring(index + search.length)
|
||||
)
|
||||
}
|
||||
|
||||
const getTitleForPostCopy = (
|
||||
title: string,
|
||||
) => {
|
||||
const numberAtEndOfTitle = title.split(" ").pop()
|
||||
if (numberAtEndOfTitle) {
|
||||
const number = parseInt(numberAtEndOfTitle)
|
||||
if (number) {
|
||||
return replaceLastInString(title, numberAtEndOfTitle, (number + 1).toString())
|
||||
} else {
|
||||
return title + " 1"
|
||||
}
|
||||
} else {
|
||||
return title + " 1"
|
||||
}
|
||||
const getTitleForPostCopy = (title: string) => {
|
||||
const numberAtEndOfTitle = title.split(" ").pop()
|
||||
if (numberAtEndOfTitle) {
|
||||
const number = parseInt(numberAtEndOfTitle)
|
||||
if (number) {
|
||||
return replaceLastInString(
|
||||
title,
|
||||
numberAtEndOfTitle,
|
||||
(number + 1).toString()
|
||||
)
|
||||
} else {
|
||||
return title + " 1"
|
||||
}
|
||||
} else {
|
||||
return title + " 1"
|
||||
}
|
||||
}
|
||||
|
||||
export default getTitleForPostCopy
|
||||
export default getTitleForPostCopy
|
||||
|
Loading…
Reference in New Issue