dreaction-react-native 1.7.1 → 1.7.2
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.
|
@@ -56,7 +56,7 @@ exports.ConfigDialog = react_1.default.memo((props) => {
|
|
|
56
56
|
});
|
|
57
57
|
}, []);
|
|
58
58
|
const handleConfirm = () => {
|
|
59
|
-
const host = (0, parseURL_1.
|
|
59
|
+
const host = (0, parseURL_1.getHostWithPortFromUrl)(inputValue);
|
|
60
60
|
dreaction_1.dreaction.asyncStorageHandler?.setItem(LOCAL_CACHE_HOST_NAME, host);
|
|
61
61
|
onConfirm(host);
|
|
62
62
|
};
|
|
@@ -6,4 +6,10 @@
|
|
|
6
6
|
* @returns {string} host of given URL or throws
|
|
7
7
|
*/
|
|
8
8
|
export declare function getHostFromUrl(url: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Extract host:port from URL
|
|
11
|
+
* @param url URL string
|
|
12
|
+
* @returns host:port string or throws if invalid
|
|
13
|
+
*/
|
|
14
|
+
export declare function getHostWithPortFromUrl(url: string): string;
|
|
9
15
|
//# sourceMappingURL=parseURL.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseURL.d.ts","sourceRoot":"","sources":["../../src/helpers/parseURL.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,UAUzC"}
|
|
1
|
+
{"version":3,"file":"parseURL.d.ts","sourceRoot":"","sources":["../../src/helpers/parseURL.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,UAUzC;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,UAWjD"}
|
package/lib/helpers/parseURL.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getHostFromUrl = getHostFromUrl;
|
|
4
|
+
exports.getHostWithPortFromUrl = getHostWithPortFromUrl;
|
|
4
5
|
/**
|
|
5
6
|
* Given a valid http(s) URL, the host for the given URL
|
|
6
7
|
* is returned.
|
|
@@ -19,3 +20,18 @@ function getHostFromUrl(url) {
|
|
|
19
20
|
throw new Error("Invalid URL - host not found");
|
|
20
21
|
return host;
|
|
21
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Extract host:port from URL
|
|
25
|
+
* @param url URL string
|
|
26
|
+
* @returns host:port string or throws if invalid
|
|
27
|
+
*/
|
|
28
|
+
function getHostWithPortFromUrl(url) {
|
|
29
|
+
const hostWithPort = url
|
|
30
|
+
.replace(/^(?:https?:\/\/)?/, '')
|
|
31
|
+
.split(/[/?#]/)[0]
|
|
32
|
+
.trim();
|
|
33
|
+
if (!hostWithPort) {
|
|
34
|
+
throw new Error('Invalid URL - host not found');
|
|
35
|
+
}
|
|
36
|
+
return hostWithPort;
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dreaction-react-native",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"author": "moonrailgun <moonrailgun@gmail.com>",
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"dreaction-
|
|
19
|
-
"dreaction-
|
|
18
|
+
"dreaction-client-core": "1.2.0",
|
|
19
|
+
"dreaction-protocol": "1.0.8"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@react-native-async-storage/async-storage": "^2.1.0",
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from 'react-native';
|
|
10
10
|
import { getHost } from '../helpers/getHost';
|
|
11
11
|
import { dreaction } from '../dreaction';
|
|
12
|
-
import {
|
|
12
|
+
import { getHostWithPortFromUrl } from '../helpers/parseURL';
|
|
13
13
|
|
|
14
14
|
const LOCAL_CACHE_HOST_NAME = '__dreaction-react-native-host';
|
|
15
15
|
|
|
@@ -36,7 +36,7 @@ export const ConfigDialog: React.FC<ConfigDialogProps> = React.memo((props) => {
|
|
|
36
36
|
}, []);
|
|
37
37
|
|
|
38
38
|
const handleConfirm = () => {
|
|
39
|
-
const host =
|
|
39
|
+
const host = getHostWithPortFromUrl(inputValue);
|
|
40
40
|
dreaction.asyncStorageHandler?.setItem(LOCAL_CACHE_HOST_NAME, host);
|
|
41
41
|
onConfirm(host);
|
|
42
42
|
};
|
package/src/helpers/parseURL.ts
CHANGED
|
@@ -17,3 +17,21 @@ export function getHostFromUrl(url: string) {
|
|
|
17
17
|
|
|
18
18
|
return host
|
|
19
19
|
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Extract host:port from URL
|
|
23
|
+
* @param url URL string
|
|
24
|
+
* @returns host:port string or throws if invalid
|
|
25
|
+
*/
|
|
26
|
+
export function getHostWithPortFromUrl(url: string) {
|
|
27
|
+
const hostWithPort = url
|
|
28
|
+
.replace(/^(?:https?:\/\/)?/, '')
|
|
29
|
+
.split(/[/?#]/)[0]
|
|
30
|
+
.trim();
|
|
31
|
+
|
|
32
|
+
if (!hostWithPort) {
|
|
33
|
+
throw new Error('Invalid URL - host not found');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return hostWithPort;
|
|
37
|
+
}
|