abmp-npm 2.0.78 → 2.0.80

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abmp-npm",
3
- "version": "2.0.78",
3
+ "version": "2.0.80",
4
4
  "main": "index.js",
5
5
  "files": [
6
6
  "index.js",
package/pages/Home.js CHANGED
@@ -3,12 +3,12 @@ const { location: wixLocation } = require('@wix/site-location');
3
3
  const { window: wixWindow, rendering } = require('@wix/site-window');
4
4
  const { withWarmUpData } = require('psdev-utils/frontend');
5
5
 
6
- const { ADDRESS_STATUS_TYPES, DEFAULT_FILTER, DROPDOWN_OPTIONS } = require('../public/consts.js');
6
+ const { DEFAULT_FILTER, DROPDOWN_OPTIONS } = require('../public/consts.js');
7
7
  const { createHomepageUtils } = require('../public/Utils/homePage.js');
8
8
  const {
9
9
  getMainAddress,
10
+ findMainAddress,
10
11
  formatPracticeAreasForDisplay,
11
- checkAddressIsVisible,
12
12
  isWixHostedImage,
13
13
  normalizeExternalUrl,
14
14
  buildMapLink,
@@ -226,25 +226,24 @@ const homePageOnReady = async ({
226
226
  $item('#milesAwayText').text = '';
227
227
  }
228
228
 
229
- // 7) "Show maps" button shown only when we can actually build a link for it
230
- const visible = checkAddressIsVisible(addresses);
231
- const fullAddressWithValidCoords = visible.find(
232
- addr =>
233
- addr.addressStatus === ADDRESS_STATUS_TYPES.FULL_ADDRESS &&
234
- addr.latitude &&
235
- addr.longitude
236
- );
237
-
238
- // Links to the street address rather than the stored coordinates, which are
239
- // unreliable for some members. The full-address filter above is what keeps
240
- // this safe: members set to state_city_zip or dont_show never reach here, so
241
- // a hidden street address is never put in a maps URL.
229
+ // 7) "Show maps" button - directions to whatever address the member displays.
230
+ //
231
+ // Uses the same address as the location text above, so the button always
232
+ // matches what the member is showing. Members displaying city/state/ZIP get
233
+ // directions to that, rather than no button at all: their NetForum
234
+ // coordinates can be miles off (see Monday 12596102059), and the text they
235
+ // publish is the reliable value.
236
+ //
237
+ // Privacy is enforced in buildMapLink, not here - it delegates to
238
+ // formatAddress, which prints the street line only for full_address, and
239
+ // returns '' outright for dont_show. findMainAddress also excludes
240
+ // dont_show. A hidden street address can never reach a maps URL.
242
241
  //
243
- // Gate on the link rather than on the address. buildMapLink returns '' when
244
- // it can build neither an address nor a coordinate link, and it also handles
245
- // being passed undefined - so this cannot leave a visible button linking
246
- // nowhere, even if the filter above is later relaxed.
247
- const mapLink = buildMapLink(fullAddressWithValidCoords);
242
+ // Gate on the link rather than the address: buildMapLink returns '' when it
243
+ // can build neither an address nor a coordinate link, and handles being
244
+ // passed '' or undefined, so the button is never shown linking nowhere.
245
+ const mapAddress = findMainAddress(itemData.addressDisplayOption, addresses);
246
+ const mapLink = buildMapLink(mapAddress);
248
247
 
249
248
  if (mapLink) {
250
249
  $item('#showMaps').enable();
package/pages/Profile.js CHANGED
@@ -6,6 +6,7 @@ const {
6
6
  generateId,
7
7
  formatPracticeAreasForDisplay,
8
8
  isWixHostedImage,
9
+ normalizeExternalUrl,
9
10
  } = require('../public/Utils/sharedUtils');
10
11
 
11
12
  const TESTIMONIALS_PER_PAGE_CONFIG = {
@@ -159,7 +160,11 @@ async function profileOnReady({ $w: _$w }) {
159
160
 
160
161
  function bindBookingUrl() {
161
162
  if (profileData.bookingUrl) {
162
- _$w('#bookNowButton').link = profileData.bookingUrl;
163
+ // Normalised for the same reason the directory does it (see Home.js): some
164
+ // stored booking URLs have no protocol, and a bare hostname would be treated
165
+ // as a path on this site rather than an external link, so the button would
166
+ // point at abmpmembers.com/<their-domain> and go nowhere.
167
+ _$w('#bookNowButton').link = normalizeExternalUrl(profileData.bookingUrl);
163
168
  } else {
164
169
  _$w('#bookNowButton').delete();
165
170
  }
@@ -12,13 +12,24 @@ function isNotValidUrl(url) {
12
12
  // Empty URLs are considered valid (optional field)
13
13
  if (!url) return false;
14
14
 
15
- // URL must start with protocol OR www - handles all TLDs including multi-level and query params
16
- // NOTE: the host class is `[\da-z.-]` (digit, letter, dot, hyphen). It previously read
17
- // `[da-z.-]`, which - missing the backslash - matched only a literal "d" plus a-z, so any
18
- // domain containing a digit was rejected (e.g. https://patty-10439.square.site).
19
- // The `i` flag keeps mixed-case hosts valid; domains are case-insensitive.
15
+ // Handles all TLDs including multi-level, plus paths, query strings and anchors.
16
+ //
17
+ // The protocol is OPTIONAL. Members routinely type a bare hostname such as
18
+ // "patty-10439.square.site", which is what they see in their browser. Requiring
19
+ // http:// or www. rejected that and blocked the whole Business & Services save.
20
+ // getContactAndBookingData already runs the value through normalizeExternalUrl on
21
+ // save, so a bare hostname is stored with https:// prepended - accepting it here
22
+ // is what lets that happen.
23
+ //
24
+ // Dropping the explicit `www.` branch loses nothing: "www.example.com" still
25
+ // matches as host "www.example" plus TLD ".com".
26
+ //
27
+ // The host class is `[\da-z.-]` (digit, letter, dot, hyphen). It once read
28
+ // `[da-z.-]`, which - missing the backslash - matched only a literal "d" plus a-z,
29
+ // so any domain containing a digit was rejected. The `i` flag keeps mixed-case
30
+ // hosts valid; domains are case-insensitive.
20
31
  const urlRegex =
21
- /^(https?:\/\/|www\.)([\da-z.-]+)\.([a-z.]{2,})([/\w .-]*)*(\?[&\w=.-]*)?(#[&\w=.-]*)?\/?$/i;
32
+ /^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,})([/\w .-]*)*(\?[&\w=.-]*)?(#[&\w=.-]*)?\/?$/i;
22
33
 
23
34
  return !urlRegex.test(url);
24
35
  }
@@ -137,6 +137,12 @@ function formatAddress(item) {
137
137
  function buildMapLink(address) {
138
138
  if (!address) return '';
139
139
 
140
+ // A member set to dont_show has opted out of publishing their location at all.
141
+ // formatAddress returns '' for them, so without this guard they would fall
142
+ // through to the coordinate fallback below and have their exact position put
143
+ // into an outbound maps URL - worse than the street line they chose to hide.
144
+ if (address.addressStatus === ADDRESS_STATUS_TYPES.DONT_SHOW) return '';
145
+
140
146
  const query = formatAddress(address);
141
147
  if (query) {
142
148
  return `https://maps.google.com/?q=${encodeURIComponent(query)}`;