Skip to content

Instantly share code, notes, and snippets.

@JamoCA
Last active May 10, 2021 23:25
Show Gist options
  • Save JamoCA/6f46af76a3f8b9975ccc0623602a92f1 to your computer and use it in GitHub Desktop.
Save JamoCA/6f46af76a3f8b9975ccc0623602a92f1 to your computer and use it in GitHub Desktop.
ColdFusion UDF to remove optional "dots" and "plus addressing" from Gmail addresses to normalize the username. (Created due to comment spam from randomized gmail usernames.)
<cfscript>
string function sanitizeGmail(required string email) output=false hint="I strip dot notation and plus extras from a gmail address" {
if (listLast(trim(arguments.email),"@") is "gmail.com"){
local.username = ListFirst(trim(arguments.email), "@");
local.username = replace(listFirst(local.username, "+"), ".", "", "all");
arguments.email = local.username & "@gmail.com";
}
return arguments.email;
}
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment