universal-parcel-scraper 0.654.0-main.3113 → 0.654.1-main.3115

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -411,7 +411,8 @@ function candidates(data, key, carriers) {
411
411
  export function locatePlace(location, hints = {}) {
412
412
  return locate(location, hints)?.place ?? null;
413
413
  }
414
- function locate(location, hints) {
414
+ /** `split` reads a country the text names apart from its town; without it the whole text is the town's. */
415
+ function locate(location, hints, split = true) {
415
416
  const text = location?.trim();
416
417
  // A military post office's base can be anywhere in its region (`militaryPostOffice`).
417
418
  if (!text || militaryPostOffice(text))
@@ -420,7 +421,7 @@ function locate(location, hints) {
420
421
  if (facility)
421
422
  return { place: facility, text: true };
422
423
  const data = gazetteer();
423
- const explicit = trackingPlace(text);
424
+ const explicit = split ? trackingPlace(text) : { country: null, place: text };
424
425
  let country = explicit.country && data.countries.has(explicit.country) ? explicit.country : null;
425
426
  let rest = explicit.country ? explicit.place : text;
426
427
  const context = hints.countries ?? [];
@@ -569,6 +570,16 @@ function locate(location, hints) {
569
570
  },
570
571
  };
571
572
  }
573
+ // A hub named after a city that shares a country's name: GIG Logistics' "BENIN HUB"
574
+ // is in Benin City. On a parcel in the city's country, and not in the named one, the
575
+ // city it is, when it is a large one.
576
+ const facilityWords = tokens(rest);
577
+ if (country && !context.includes(country) && text.endsWith(rest) && facilityWords.length
578
+ && facilityWords.every((token) => FACILITY_WORDS.has(token.key))) {
579
+ const town = locate(text, hints, false);
580
+ if (town?.place.precision === 'city' && context.includes(town.place.country) && (town.thousands ?? 0) >= NAMESAKE_THOUSANDS)
581
+ return town;
582
+ }
572
583
  // A two-letter code with no town of its country before it, on a parcel nothing else puts
573
584
  // there, may be no country at all: Royal Mail ends its mail centres with MC and its
574
585
  // delivery offices with DO, India's states are written like countries. A town the text
@@ -2,7 +2,7 @@
2
2
  "openapi": "3.1.0",
3
3
  "info": {
4
4
  "title": "Universal Parcel Scraper",
5
- "version": "0.654.0"
5
+ "version": "0.654.1"
6
6
  },
7
7
  "paths": {
8
8
  "/health": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "universal-parcel-scraper",
3
- "version": "0.654.0-main.3113",
3
+ "version": "0.654.1-main.3115",
4
4
  "description": "Self-hosted parcel tracking: carrier detection, dedicated scrapers and optional universal providers.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",