aboutsummaryrefslogtreecommitdiffstats
path: root/src/gun_public_suffix.erl.src
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2020-03-04 16:50:16 +0100
committerLoïc Hoguin <[email protected]>2020-03-05 11:33:59 +0100
commita5ab2d83bb5e62e874d91fd6c86022db4baa908c (patch)
tree25c598e3f24af4c9ebedd475efb6ec1854dc6f86 /src/gun_public_suffix.erl.src
parent4e10d5c132a7b3a72f035eb1a993eb378b97ab1d (diff)
downloadgun-a5ab2d83bb5e62e874d91fd6c86022db4baa908c.tar.gz
gun-a5ab2d83bb5e62e874d91fd6c86022db4baa908c.tar.bz2
gun-a5ab2d83bb5e62e874d91fd6c86022db4baa908c.zip
Add the public suffix check to set_cookie
Diffstat (limited to 'src/gun_public_suffix.erl.src')
-rw-r--r--src/gun_public_suffix.erl.src29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/gun_public_suffix.erl.src b/src/gun_public_suffix.erl.src
new file mode 100644
index 0000000..b6b8c62
--- /dev/null
+++ b/src/gun_public_suffix.erl.src
@@ -0,0 +1,29 @@
+%% Copyright (c) 2020, Loïc Hoguin <[email protected]>
+%%
+%% Permission to use, copy, modify, and/or distribute this software for any
+%% purpose with or without fee is hereby granted, provided that the above
+%% copyright notice and this permission notice appear in all copies.
+%%
+%% THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+%% WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+%% MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+%% ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+%% WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+%% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+%% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+-module(gun_public_suffix).
+-compile(no_type_opt). %% Until at least OTP-23.
+
+-export([match/1]).
+
+-spec match(binary()) -> boolean().
+match(Domain) ->
+ Subdomains = string:split(Domain, <<".">>, all),
+ m(Subdomains).
+
+%% GENERATED_M
+m(_) -> false.
+
+%% GENERATED_E
+e(_) -> true.