mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-07 13:15:28 +02:00
Fix renderSubstr() with start > 0
This commit is contained in:
parent
257081b250
commit
6283a047f3
1 changed files with 4 additions and 3 deletions
|
@ -256,7 +256,8 @@ function renderSubstr(str, start, length) {
|
||||||
|
|
||||||
if(match) {
|
if(match) {
|
||||||
if(match.index > pos) {
|
if(match.index > pos) {
|
||||||
const s = str.slice(pos, match.index - (Math.min(0, length - renderLen)));
|
const s = str.slice(pos + start, match.index - (Math.min(0, length - renderLen)));
|
||||||
|
start = 0; // start offset applies only once
|
||||||
out += s;
|
out += s;
|
||||||
renderLen += s.length;
|
renderLen += s.length;
|
||||||
}
|
}
|
||||||
|
@ -266,8 +267,8 @@ function renderSubstr(str, start, length) {
|
||||||
} while(renderLen < length && 0 !== re.lastIndex);
|
} while(renderLen < length && 0 !== re.lastIndex);
|
||||||
|
|
||||||
// remainder
|
// remainder
|
||||||
if(pos < str.length && renderLen < length) {
|
if(pos + start < str.length && renderLen < length) {
|
||||||
out += str.slice(pos, pos + Math.max(0, length - renderLen));
|
out += str.slice(pos + start, pos + Math.max(0, length - renderLen));
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue