fix(ui): guard parseColoredText against non-string inputs
This commit is contained in:
parent
7e46fab753
commit
a08b837ba5
|
|
@ -113,6 +113,9 @@ export function parseFontTblMetrics(tblBytes: Uint8Array): {
|
||||||
* Split a string containing Diablo II `ÿcX` color codes into colored spans.
|
* Split a string containing Diablo II `ÿcX` color codes into colored spans.
|
||||||
*/
|
*/
|
||||||
export function parseColoredText(input: string, defaultColor: D2ColorCode = 'white'): TextSpan[] {
|
export function parseColoredText(input: string, defaultColor: D2ColorCode = 'white'): TextSpan[] {
|
||||||
|
if (!input || typeof input !== 'string') {
|
||||||
|
return []
|
||||||
|
}
|
||||||
const spans: TextSpan[] = []
|
const spans: TextSpan[] = []
|
||||||
let currentColor: D2ColorCode = defaultColor
|
let currentColor: D2ColorCode = defaultColor
|
||||||
let buf = ''
|
let buf = ''
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue