* Consume an unquoted url token. Caller has already eaten `url(` and * any leading whitespace. * @param {string} input input * @param {number} pos position at the first content code point * @param {number} fnStart byte offset of the `u` in `url(` * @param {MutableToken} out token to populate *
(input, pos, fnStart, out)
| 787 | * @returns {MutableToken | undefined} the resulting token, or undefined at EOF |
| 788 | */ |
| 789 | function consumeAUrlToken(input, pos, fnStart, out) { |
| 790 | while (_isWhiteSpace(input.charCodeAt(pos))) pos++; |
| 791 | const contentStart = pos; |
| 792 | out.contentStart = contentStart; |
| 793 | for (;;) { |
| 794 | if (pos === input.length) { |
| 795 | out.contentEnd = pos - 1; |
| 796 | return fill(out, TT_URL, fnStart, pos); |
| 797 | } |
| 798 | const cc = input.charCodeAt(pos); |
| 799 | pos++; |
| 800 | if (cc === CC_RIGHT_PARENTHESIS) { |
| 801 | out.contentEnd = pos - 1; |
| 802 | return fill(out, TT_URL, fnStart, pos); |
| 803 | } |
| 804 | if (_isWhiteSpace(cc)) { |
| 805 | const end = pos - 1; |
| 806 | while (_isWhiteSpace(input.charCodeAt(pos))) pos++; |
| 807 | if (pos === input.length) { |
| 808 | out.contentEnd = end; |
| 809 | return fill(out, TT_URL, fnStart, pos); |
| 810 | } |
| 811 | if (input.charCodeAt(pos) === CC_RIGHT_PARENTHESIS) { |
| 812 | pos++; |
| 813 | out.contentEnd = end; |
| 814 | return fill(out, TT_URL, fnStart, pos); |
| 815 | } |
| 816 | pos = _consumeTheRemnantsOfABadUrl(input, pos); |
| 817 | return fill(out, TT_BAD_URL_TOKEN, fnStart, pos); |
| 818 | } |
| 819 | if ( |
| 820 | cc === CC_QUOTATION_MARK || |
| 821 | cc === CC_APOSTROPHE || |
| 822 | cc === CC_LEFT_PARENTHESIS || |
| 823 | _isNonPrintableCodePoint(cc) |
| 824 | ) { |
| 825 | pos = _consumeTheRemnantsOfABadUrl(input, pos); |
| 826 | return fill(out, TT_BAD_URL_TOKEN, fnStart, pos); |
| 827 | } |
| 828 | if (cc === CC_REVERSE_SOLIDUS) { |
| 829 | if (_ifTwoCodePointsAreValidEscape(input, pos)) { |
| 830 | pos = _consumeAnEscapedCodePoint(input, pos); |
| 831 | } else { |
| 832 | pos = _consumeTheRemnantsOfABadUrl(input, pos); |
| 833 | return fill(out, TT_BAD_URL_TOKEN, fnStart, pos); |
| 834 | } |
| 835 | } |
| 836 | } |
| 837 | } |
| 838 | |
| 839 | /** |
| 840 | * Consume an ident-like token: ident / function / url / bad-url. |
no test coverage detected