Current section
Files
Jump to
Current section
Files
src/domain_puns@punycode.erl
-module(domain_puns@punycode).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/domain_puns/punycode.gleam").
-export([matches_domain/1]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(" Module for working with punycode.\n").
-file("src/domain_puns/punycode.gleam", 10).
?DOC(
" Checks if a domain string is a punycode domain. If it is, it returns the punycode\n"
" string with the leading prefix for internationalized domains removed.\n"
).
-spec matches_domain(binary()) -> {ok, binary()} | {error, nil}.
matches_domain(Domain) ->
Lower = string:lowercase(Domain),
case gleam_stdlib:string_starts_with(Lower, <<"xn--"/utf8>>) of
true ->
_pipe = gleam_stdlib:string_remove_prefix(Lower, <<"xn--"/utf8>>),
{ok, _pipe};
false ->
{error, nil}
end.