( text: string, quoteCharCode: number, startIndex: number, endIndex: number, )
| 293 | * @returns Index after quoted characters. |
| 294 | */ |
| 295 | export function consumeQuotedText( |
| 296 | text: string, |
| 297 | quoteCharCode: number, |
| 298 | startIndex: number, |
| 299 | endIndex: number, |
| 300 | ): number { |
| 301 | let ch1 = -1; // 1st previous character |
| 302 | let index = startIndex; |
| 303 | while (index < endIndex) { |
| 304 | const ch = text.charCodeAt(index++); |
| 305 | if (ch == quoteCharCode && ch1 !== CharCode.BACK_SLASH) { |
| 306 | return index; |
| 307 | } |
| 308 | if (ch == CharCode.BACK_SLASH && ch1 === CharCode.BACK_SLASH) { |
| 309 | // two back slashes cancel each other out. For example `"\\"` should properly end the |
| 310 | // quotation. (It should not assume that the last `"` is escaped.) |
| 311 | ch1 = 0; |
| 312 | } else { |
| 313 | ch1 = ch; |
| 314 | } |
| 315 | } |
| 316 | throw ngDevMode |
| 317 | ? malformedStyleError(text, String.fromCharCode(quoteCharCode), endIndex) |
| 318 | : new Error(); |
| 319 | } |
| 320 | |
| 321 | function malformedStyleError(text: string, expecting: string, index: number): never { |
| 322 | ngDevMode && assertEqual(typeof text === 'string', true, 'String expected here'); |
no test coverage detected
searching dependent graphs…