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 +1 -1
- package/pages/Home.js +19 -20
- package/pages/Profile.js +6 -1
- package/public/Utils/personalDetailsUtils.js +17 -6
- package/public/Utils/sharedUtils.js +6 -0
package/package.json
CHANGED
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 {
|
|
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
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
//
|
|
239
|
-
//
|
|
240
|
-
//
|
|
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
|
|
244
|
-
//
|
|
245
|
-
//
|
|
246
|
-
|
|
247
|
-
const mapLink = buildMapLink(
|
|
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
|
-
|
|
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
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
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
|
|
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)}`;
|