isValidHostmask

Makes a cursory verification of a hostmask, ensuring that it doesn't contain invalid characters. May very well have false positives.

pure @safe nothrow @nogc
isValidHostmask
(
const string hostmask
,)

Parameters

hostmask string

Hostmask string to examine.

server IRCServer

The current IRCServer with its IRCServer.CaseMapping.

Return Value

Type: auto

true if the hostmask seems to be valid, false if it obviously is not.

Examples

IRCServer server;

{
    immutable hostmask = "*!*@*";
    assert(hostmask.isValidHostmask(server));
}
{
    immutable hostmask = "nick123`!*@*";
    assert(hostmask.isValidHostmask(server));
}
{
    immutable hostmask = "*!~ident0-9_@*";
    assert(hostmask.isValidHostmask(server));
}
{
    immutable hostmask = "*!ident0-9_@*";
    assert(hostmask.isValidHostmask(server));
}
{
    immutable hostmask = "*!~~ident0-9_@*";
    assert(!hostmask.isValidHostmask(server));
}
{
    immutable hostmask = "*!*@address.tld.net";
    assert(hostmask.isValidHostmask(server));
}
{
    immutable hostmask = "*!*@~address.tld.net";
    assert(!hostmask.isValidHostmask(server));
}
{
    immutable hostmask = "*!*@2001::ff:09:ff";
    assert(hostmask.isValidHostmask(server));
}
{
    immutable hostmask = "kameloso!~kameloso@2001*";
    assert(hostmask.isValidHostmask(server));
}
{
    immutable hostmask = "harbl*!~dolmen@*";
    assert(hostmask.isValidHostmask(server));
}

Meta