UNPKG

meta-capi-param-builder-clientjs

Version:

Conversions API parameter builder for Client-side JavaScript

29 lines (23 loc) 712 B
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. * * This source code is licensed under the license found in the * LICENSE file in the root directory of this source tree. */ import { looksLikeHashed, trim } from './piiUtil.js'; function getNormalizedZipCode(zipCode) { let normalizedZipCode = null; if (zipCode != null && typeof zipCode === 'string') { if (looksLikeHashed(zipCode)) { normalizedZipCode = zipCode; } else { const maybeZIP = trim(String(zipCode).toLowerCase().split('-', 1)[0]); if (maybeZIP.length >= 2) { normalizedZipCode = maybeZIP; } } } return normalizedZipCode; } export { getNormalizedZipCode };