@builder.io/sdk-svelte 5.2.4 → 5.2.5

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.
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "5.2.4";
1
+ export declare const SDK_VERSION = "5.2.5";
@@ -1 +1 @@
1
- export const SDK_VERSION = "5.2.4";
1
+ export const SDK_VERSION = "5.2.5";
@@ -1,8 +1,14 @@
1
1
  const DEFAULT_TRUSTED_HOSTS = ['*.beta.builder.io', 'beta.builder.io', 'builder.io', 'localhost', 'qa.builder.io'];
2
2
  export function isFromTrustedHost(trustedHosts, e) {
3
- if (!e.origin.startsWith('http') && !e.origin.startsWith('https')) {
3
+ let url;
4
+ try {
5
+ url = new URL(e.origin);
6
+ }
7
+ catch {
8
+ return false;
9
+ }
10
+ if (url.protocol !== 'http:' && url.protocol !== 'https:') {
4
11
  return false;
5
12
  }
6
- const url = new URL(e.origin), hostname = url.hostname;
7
- return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex(trustedHost => trustedHost.startsWith('*.') ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
13
+ return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex(trustedHost => trustedHost.startsWith('*.') ? url.hostname.endsWith(trustedHost.slice(1)) : trustedHost === url.hostname) > -1;
8
14
  }
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "5.2.4";
1
+ export declare const SDK_VERSION = "5.2.5";
@@ -1 +1 @@
1
- export const SDK_VERSION = "5.2.4";
1
+ export const SDK_VERSION = "5.2.5";
@@ -1,8 +1,14 @@
1
1
  const DEFAULT_TRUSTED_HOSTS = ['*.beta.builder.io', 'beta.builder.io', 'builder.io', 'localhost', 'qa.builder.io'];
2
2
  export function isFromTrustedHost(trustedHosts, e) {
3
- if (!e.origin.startsWith('http') && !e.origin.startsWith('https')) {
3
+ let url;
4
+ try {
5
+ url = new URL(e.origin);
6
+ }
7
+ catch {
8
+ return false;
9
+ }
10
+ if (url.protocol !== 'http:' && url.protocol !== 'https:') {
4
11
  return false;
5
12
  }
6
- const url = new URL(e.origin), hostname = url.hostname;
7
- return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex(trustedHost => trustedHost.startsWith('*.') ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
13
+ return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex(trustedHost => trustedHost.startsWith('*.') ? url.hostname.endsWith(trustedHost.slice(1)) : trustedHost === url.hostname) > -1;
8
14
  }
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "5.2.4";
1
+ export declare const SDK_VERSION = "5.2.5";
@@ -1 +1 @@
1
- export const SDK_VERSION = "5.2.4";
1
+ export const SDK_VERSION = "5.2.5";
@@ -1,8 +1,14 @@
1
1
  const DEFAULT_TRUSTED_HOSTS = ['*.beta.builder.io', 'beta.builder.io', 'builder.io', 'localhost', 'qa.builder.io'];
2
2
  export function isFromTrustedHost(trustedHosts, e) {
3
- if (!e.origin.startsWith('http') && !e.origin.startsWith('https')) {
3
+ let url;
4
+ try {
5
+ url = new URL(e.origin);
6
+ }
7
+ catch {
8
+ return false;
9
+ }
10
+ if (url.protocol !== 'http:' && url.protocol !== 'https:') {
4
11
  return false;
5
12
  }
6
- const url = new URL(e.origin), hostname = url.hostname;
7
- return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex(trustedHost => trustedHost.startsWith('*.') ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
13
+ return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex(trustedHost => trustedHost.startsWith('*.') ? url.hostname.endsWith(trustedHost.slice(1)) : trustedHost === url.hostname) > -1;
8
14
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-svelte",
3
3
  "description": "Builder.io SDK for Svelte",
4
- "version": "5.2.4",
4
+ "version": "5.2.5",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "lib",
@@ -1 +1 @@
1
- export const SDK_VERSION = "5.2.4"
1
+ export const SDK_VERSION = "5.2.5"
@@ -2,10 +2,14 @@ const DEFAULT_TRUSTED_HOSTS = ['*.beta.builder.io', 'beta.builder.io', 'builder.
2
2
  export function isFromTrustedHost(trustedHosts: string[] | undefined, e: {
3
3
  origin: string;
4
4
  }): boolean {
5
- if (!e.origin.startsWith('http') && !e.origin.startsWith('https')) {
5
+ let url: URL;
6
+ try {
7
+ url = new URL(e.origin);
8
+ } catch {
6
9
  return false;
7
10
  }
8
- const url = new URL(e.origin),
9
- hostname = url.hostname;
10
- return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex(trustedHost => trustedHost.startsWith('*.') ? hostname.endsWith(trustedHost.slice(1)) : trustedHost === hostname) > -1;
11
+ if (url.protocol !== 'http:' && url.protocol !== 'https:') {
12
+ return false;
13
+ }
14
+ return (trustedHosts || DEFAULT_TRUSTED_HOSTS).findIndex(trustedHost => trustedHost.startsWith('*.') ? url.hostname.endsWith(trustedHost.slice(1)) : trustedHost === url.hostname) > -1;
11
15
  }