INNER CODE UNIT · TypeScript

hasAngleAddress

postalsys/postal-mime · src/address-parser.ts:79

function hasAngleAddress(text: string): boolean {
    // position right after the `<` that opened the current bracket, or -1
    let start = -1;
    // first '@' inside the bracket that has a character before it, or -1
    let at = -1;

    for (let i = 0; i < text.length; i++) {
        const chr = text.charAt(i);
        if (chr === '<') {
            start = i + 1;
            at = -1;
        } else if (chr === '>') {
            if (at >= 0 && at < i - 1) {
                return true;
            }
            start = -1;
            at = -1;
        } else if (chr === '@' && start >= 0 && at < 0 && i > start) {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…