@maxzima/wa-communicator 0.0.7 → 0.0.8
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/dist/engine/CommunicatorReceiver.js +2 -1
- package/dist/engine/CommunicatorSender.js +2 -2
- package/dist/engine/utils.d.ts +1 -1
- package/dist/engine/utils.js +2 -2
- package/package.json +1 -1
- package/src/engine/CommunicatorReceiver.ts +2 -1
- package/src/engine/CommunicatorSender.ts +2 -2
- package/src/engine/utils.ts +2 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { modifyOrigin } from "./utils";
|
|
1
2
|
export class CommunicatorReceiver {
|
|
2
3
|
constructor(props) {
|
|
3
4
|
this.onMessage = (event) => {
|
|
@@ -21,7 +22,7 @@ export class CommunicatorReceiver {
|
|
|
21
22
|
this.callback(message);
|
|
22
23
|
};
|
|
23
24
|
this.callback = props.callback;
|
|
24
|
-
this.senderOrigin = props.senderOrigin;
|
|
25
|
+
this.senderOrigin = modifyOrigin(props.senderOrigin);
|
|
25
26
|
}
|
|
26
27
|
watch() {
|
|
27
28
|
window.addEventListener('message', this.onMessage, false);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { modifyOrigin } from './utils';
|
|
2
2
|
import { CommunicatorTargetEnum_isCorrect } from '../enums/CommunicatorTargetEnum';
|
|
3
3
|
export class CommunicatorSender {
|
|
4
4
|
constructor(props) {
|
|
5
5
|
this.otherWindow = props.otherWindow;
|
|
6
|
-
this.receiverOrigin =
|
|
6
|
+
this.receiverOrigin = modifyOrigin(props.receiverOrigin);
|
|
7
7
|
}
|
|
8
8
|
sendMessage(message) {
|
|
9
9
|
if (!this.receiverOrigin ||
|
package/dist/engine/utils.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function modifyOrigin(address: string): string;
|
package/dist/engine/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function modifyOrigin(address) {
|
|
2
2
|
let url;
|
|
3
3
|
try {
|
|
4
4
|
let targetOrigin = address.trim();
|
|
@@ -8,5 +8,5 @@ export function modifyUrl(address) {
|
|
|
8
8
|
catch (_) {
|
|
9
9
|
return null;
|
|
10
10
|
}
|
|
11
|
-
return url.
|
|
11
|
+
return url.origin;
|
|
12
12
|
}
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {TCommunicatorMessage, TReceiverCallback, TReceiverProps} from '../types';
|
|
2
|
+
import {modifyOrigin} from "./utils";
|
|
2
3
|
|
|
3
4
|
export class CommunicatorReceiver {
|
|
4
5
|
private readonly callback: TReceiverCallback;
|
|
@@ -6,7 +7,7 @@ export class CommunicatorReceiver {
|
|
|
6
7
|
|
|
7
8
|
constructor(props: TReceiverProps) {
|
|
8
9
|
this.callback = props.callback;
|
|
9
|
-
this.senderOrigin = props.senderOrigin;
|
|
10
|
+
this.senderOrigin = modifyOrigin(props.senderOrigin);
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {TCommunicatorMessage, TSenderProps} from '../types';
|
|
2
|
-
import {
|
|
2
|
+
import {modifyOrigin} from './utils';
|
|
3
3
|
import {CommunicatorTargetEnum_isCorrect} from '../enums/CommunicatorTargetEnum';
|
|
4
4
|
|
|
5
5
|
export class CommunicatorSender {
|
|
@@ -8,7 +8,7 @@ export class CommunicatorSender {
|
|
|
8
8
|
|
|
9
9
|
constructor(props: TSenderProps) {
|
|
10
10
|
this.otherWindow = props.otherWindow;
|
|
11
|
-
this.receiverOrigin =
|
|
11
|
+
this.receiverOrigin = modifyOrigin(props.receiverOrigin);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
/**
|
package/src/engine/utils.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function modifyOrigin(address: string): string {
|
|
2
2
|
let url: URL;
|
|
3
3
|
try {
|
|
4
4
|
let targetOrigin = address.trim();
|
|
@@ -7,5 +7,5 @@ export function modifyUrl(address: string): string {
|
|
|
7
7
|
} catch (_) {
|
|
8
8
|
return null;
|
|
9
9
|
}
|
|
10
|
-
return url.
|
|
10
|
+
return url.origin;
|
|
11
11
|
}
|