@wix/himalaya-cli 0.1602.0 → 0.1604.0

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.
@@ -624,6 +624,13 @@ export interface PushConfig {
624
624
  * account-level app that is not about any single site. Only the "wix-ping"
625
625
  * registrar reads it. */
626
626
  pingScope?: "site" | "user";
627
+ /** Extra link prefixes stripped before `routes` match (#4709), for an app inheriting a
628
+ * legacy link space: e.g. `["legacyapp://", "https://legacy.example.com/app/"]` turns
629
+ * `legacyapp://widget/42` into the residual `widget/42`. Tried after the "wix-ping"
630
+ * rules; the longest matching prefix wins; scheme and host compare case-insensitively,
631
+ * the path exactly, and a prefix ends at `/`, `?` or `#`. A relative link (`/widget/42`)
632
+ * is a residual without any prefix. */
633
+ linkPrefixes?: string[];
627
634
  /** Token registrar. "generic" ⇒ POST the token to `registerUrl`; "wix-ping"
628
635
  * ⇒ the native Wix Ping registrar. */
629
636
  registrar: PushRegistrar;
@@ -49,8 +49,13 @@ export interface AdaptedLink {
49
49
  * link through unchanged rather than failing, so an older binary served a config
50
50
  * naming an adapter it has never heard of degrades to today's behavior instead of
51
51
  * dropping every notification (invariants 6/8).
52
+ *
53
+ * #4709 — `linkPrefixes` (`PushConfig.linkPrefixes`). In order: the "wix-ping" rules
54
+ * (when that is the adapter); then the LONGEST configured prefix the link starts with
55
+ * is stripped; then a relative link (`/widget/7`) is a residual as is. Anything else
56
+ * passes through unchanged. Only a Wix link yields a `metaSiteId`.
52
57
  */
53
- export declare function adaptPayloadLink(link: string, adapter?: string): AdaptedLink;
58
+ export declare function adaptPayloadLink(link: string, adapter?: string, linkPrefixes?: readonly string[]): AdaptedLink;
54
59
  /**
55
60
  * The himi link the first matching route produces, or null when nothing matches.
56
61
  *
@@ -67,6 +72,7 @@ export declare function matchPushRoute(residual: string, routes: readonly PushRo
67
72
  export declare function resolvePushRoute(link: string, config: {
68
73
  routes?: readonly PushRoute[];
69
74
  payloadAdapter?: string;
75
+ linkPrefixes?: readonly string[];
70
76
  } | undefined, payload?: PushPayloadContext): {
71
77
  link: string | null;
72
78
  params: Record<string, string>;
@@ -45,8 +45,17 @@ function redactFrogParam(value) {
45
45
  return value;
46
46
  }
47
47
  var BARE_ENDPOINT = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
48
+ function onConfigOrigin(name, configEndpoint) {
49
+ if (!configEndpoint || !configEndpoint.includes("://")) return name;
50
+ try {
51
+ const url = new URL(configEndpoint);
52
+ return `${url.protocol}//${url.host}/${name}`;
53
+ } catch {
54
+ return name;
55
+ }
56
+ }
48
57
  function eventEndpoint(eventEndpointValue, configEndpoint) {
49
- return frogEndpointUrl(eventEndpointValue && BARE_ENDPOINT.test(eventEndpointValue) ? eventEndpointValue : configEndpoint);
58
+ return frogEndpointUrl(eventEndpointValue && BARE_ENDPOINT.test(eventEndpointValue) ? onConfigOrigin(eventEndpointValue, configEndpoint) : configEndpoint);
50
59
  }
51
60
  function frogEndpointUrl(endpoint) {
52
61
  const e = (endpoint ?? "").trim() || ONEAPP_DEFAULT_ENDPOINT;