@vercel/edge
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -143,2 +143,6 @@ interface ModifiedRequest { | ||
/** | ||
* Unicode characters for emoji flags start at this number, and run up to 127469. | ||
*/ | ||
declare const EMOJI_FLAG_UNICODE_STARTING_POSITION = 127397; | ||
/** | ||
* We define a new type so this function can be reused with | ||
@@ -160,2 +164,4 @@ * the global `Request`, `node-fetch` and other types. | ||
country?: string; | ||
/** The flag emoji for the country the request originated from. */ | ||
flag?: string; | ||
/** The [Vercel Edge Network region](https://vercel.com/docs/concepts/edge-network/regions) that received the request. */ | ||
@@ -272,2 +278,2 @@ region?: string; | ||
export { CITY_HEADER_NAME, COUNTRY_HEADER_NAME, ExtraResponseInit, Geo, IP_HEADER_NAME, LATITUDE_HEADER_NAME, LONGITUDE_HEADER_NAME, ModifiedRequest, REGION_HEADER_NAME, REQUEST_ID_HEADER_NAME, RequestContext, geolocation, ipAddress, json, next, rewrite }; | ||
export { CITY_HEADER_NAME, COUNTRY_HEADER_NAME, EMOJI_FLAG_UNICODE_STARTING_POSITION, ExtraResponseInit, Geo, IP_HEADER_NAME, LATITUDE_HEADER_NAME, LONGITUDE_HEADER_NAME, ModifiedRequest, REGION_HEADER_NAME, REQUEST_ID_HEADER_NAME, RequestContext, geolocation, ipAddress, json, next, rewrite }; |
@@ -25,2 +25,3 @@ "use strict"; | ||
COUNTRY_HEADER_NAME: () => COUNTRY_HEADER_NAME, | ||
EMOJI_FLAG_UNICODE_STARTING_POSITION: () => EMOJI_FLAG_UNICODE_STARTING_POSITION, | ||
IP_HEADER_NAME: () => IP_HEADER_NAME, | ||
@@ -81,5 +82,12 @@ LATITUDE_HEADER_NAME: () => LATITUDE_HEADER_NAME, | ||
var REQUEST_ID_HEADER_NAME = "x-vercel-id"; | ||
var EMOJI_FLAG_UNICODE_STARTING_POSITION = 127397; | ||
function getHeader(request, key) { | ||
return request.headers.get(key) ?? void 0; | ||
} | ||
function getFlag(countryCode) { | ||
const regex = new RegExp("^[A-Z]{2}$").test(countryCode); | ||
if (!countryCode || !regex) | ||
return void 0; | ||
return String.fromCodePoint(...countryCode.split("").map((char) => EMOJI_FLAG_UNICODE_STARTING_POSITION + char.charCodeAt(0))); | ||
} | ||
function ipAddress(request) { | ||
@@ -98,2 +106,3 @@ return getHeader(request, IP_HEADER_NAME); | ||
country: getHeader(request, COUNTRY_HEADER_NAME), | ||
flag: getFlag(getHeader(request, COUNTRY_HEADER_NAME)), | ||
countryRegion: getHeader(request, REGION_HEADER_NAME), | ||
@@ -114,2 +123,3 @@ region: getRegionFromRequestId(getHeader(request, REQUEST_ID_HEADER_NAME)), | ||
COUNTRY_HEADER_NAME, | ||
EMOJI_FLAG_UNICODE_STARTING_POSITION, | ||
IP_HEADER_NAME, | ||
@@ -116,0 +126,0 @@ LATITUDE_HEADER_NAME, |
{ | ||
"name": "@vercel/edge", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28459
489