MCPcopy Create free account
hub / github.com/GothenburgBitFactory/taskwarrior / isURL

Method isURL

src/Lexer.cpp:605–629  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////////// Lexer::Type::url http [s] :// ...

Source from the content-addressed store, hash-verified

603// Lexer::Type::url
604// http [s] :// ...
605bool Lexer::isURL(std::string& token, Lexer::Type& type) {
606 std::size_t marker = _cursor;
607
608 if (_eos - _cursor > 9 && // length 'https://*'
609 (_text[marker + 0] == 'h' || _text[marker + 0] == 'H') &&
610 (_text[marker + 1] == 't' || _text[marker + 1] == 'T') &&
611 (_text[marker + 2] == 't' || _text[marker + 2] == 'T') &&
612 (_text[marker + 3] == 'p' || _text[marker + 3] == 'P')) {
613 marker += 4;
614 if (_text[marker + 0] == 's' || _text[marker + 0] == 'S') ++marker;
615
616 if (_text[marker + 0] == ':' && _text[marker + 1] == '/' && _text[marker + 2] == '/') {
617 marker += 3;
618
619 while (marker < _eos && !unicodeWhitespace(_text[marker])) utf8_next_char(_text, marker);
620
621 token = _text.substr(_cursor, marker - _cursor);
622 type = Lexer::Type::url;
623 _cursor = marker;
624 return true;
625 }
626 }
627
628 return false;
629}
630
631////////////////////////////////////////////////////////////////////////////////
632// Lexer::Type::pair

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected