mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-04 00:15:28 +08:00
24 lines
515 B
JavaScript
24 lines
515 B
JavaScript
'use strict';
|
|
|
|
const MIN_CONTINUATION_SNAPSHOT_LEN = 32;
|
|
|
|
function trimContinuationOverlap(existing, incoming) {
|
|
if (!incoming) {
|
|
return '';
|
|
}
|
|
if (!existing) {
|
|
return incoming;
|
|
}
|
|
if (incoming.length >= MIN_CONTINUATION_SNAPSHOT_LEN && incoming.startsWith(existing)) {
|
|
return incoming.slice(existing.length);
|
|
}
|
|
if (incoming.length >= MIN_CONTINUATION_SNAPSHOT_LEN && existing.startsWith(incoming)) {
|
|
return '';
|
|
}
|
|
return incoming;
|
|
}
|
|
|
|
module.exports = {
|
|
trimContinuationOverlap,
|
|
};
|