mirror of
https://github.com/status-im/ETHReport.git
synced 2025-02-10 13:26:44 +00:00
fix string trim
This commit is contained in:
parent
4fccc3a174
commit
efdb5aeca2
@ -17,17 +17,17 @@ const SearchResults = (props) => {
|
||||
const sortedInterviews = props.data.sort((a, b) => a.name.localeCompare(b.name));
|
||||
|
||||
const getStartOffset = (text) => {
|
||||
if (text.indexOf('>') === 0) {
|
||||
return -2;
|
||||
} else if (text.indexOf('/p>') === 0) {
|
||||
if (text.indexOf('/p>') === 0) {
|
||||
return 3;
|
||||
} else if (text.indexOf('>') === 0) {
|
||||
return 1;
|
||||
} else if (text.indexOf('p>') === 0) {
|
||||
return -1;
|
||||
} else if (text.indexOf('<p>') !== 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
};
|
||||
|
||||
const getEndOffset = (text) => {
|
||||
@ -53,8 +53,8 @@ const SearchResults = (props) => {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (strpos > length && strpos !== -1 && length > 50) {
|
||||
offset = strpos - length;
|
||||
if (strpos > length && strpos !== -1 && length > 50 && text.length > length) {
|
||||
offset = strpos - (length - 50);
|
||||
firstEllipses = '<p>...</p>';
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ const SearchResults = (props) => {
|
||||
startOffset = getStartOffset(offsetText);
|
||||
endOffset = getEndOffset(offsetText);
|
||||
|
||||
const newOffsetText = startOffset ?
|
||||
const newOffsetText = startOffset !== false && startOffset !== -1 ?
|
||||
text.substr(offset + startOffset, length + offset + endOffset) :
|
||||
`<p>${text.substr(offset + 0, length + offset + endOffset)}`;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user