@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.
@@ -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 { modifyUrl } from './utils';
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 = modifyUrl(props.receiverOrigin);
6
+ this.receiverOrigin = modifyOrigin(props.receiverOrigin);
7
7
  }
8
8
  sendMessage(message) {
9
9
  if (!this.receiverOrigin ||
@@ -1 +1 @@
1
- export declare function modifyUrl(address: string): string;
1
+ export declare function modifyOrigin(address: string): string;
@@ -1,4 +1,4 @@
1
- export function modifyUrl(address) {
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.toString();
11
+ return url.origin;
12
12
  }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.7",
2
+ "version": "0.0.8",
3
3
  "name": "@maxzima/wa-communicator",
4
4
  "description": "",
5
5
  "author": "Noname",
@@ -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 {modifyUrl} from './utils';
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 = modifyUrl(props.receiverOrigin);
11
+ this.receiverOrigin = modifyOrigin(props.receiverOrigin);
12
12
  }
13
13
 
14
14
  /**
@@ -1,4 +1,4 @@
1
- export function modifyUrl(address: string): string {
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.toString();
10
+ return url.origin;
11
11
  }