u2a 2.0.0 → 2.1.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.
- package/package.json +1 -1
- package/src/commands/create.js +1 -2
- package/src/commands/remove.js +1 -1
- package/src/utils/favicon.js +1 -1
- package/src/utils/url.js +10 -3
package/package.json
CHANGED
package/src/commands/create.js
CHANGED
|
@@ -6,7 +6,6 @@ const { getFavicon } = require('../utils/favicon');
|
|
|
6
6
|
const { APPS_DIR, readDB, writeDB } = require('../utils/config');
|
|
7
7
|
const Logger = require('../utils/logger');
|
|
8
8
|
const os = require('os');
|
|
9
|
-
const { isContext } = require('vm');
|
|
10
9
|
|
|
11
10
|
const logger = new Logger('create');
|
|
12
11
|
|
|
@@ -331,7 +330,7 @@ async function createApp(url) {
|
|
|
331
330
|
logger.info(`Creating application for ${url}`);
|
|
332
331
|
|
|
333
332
|
try {
|
|
334
|
-
url = normalizeUrl(url);
|
|
333
|
+
url = await normalizeUrl(url);
|
|
335
334
|
const domain = getDomainName(url);
|
|
336
335
|
|
|
337
336
|
const db = readDB();
|
package/src/commands/remove.js
CHANGED
package/src/utils/favicon.js
CHANGED
|
@@ -13,7 +13,7 @@ async function getFavicon(url) {
|
|
|
13
13
|
|
|
14
14
|
try {
|
|
15
15
|
const domain = getDomainName(url);
|
|
16
|
-
const normalizedUrl = normalizeUrl(url);
|
|
16
|
+
const normalizedUrl = await normalizeUrl(url);
|
|
17
17
|
|
|
18
18
|
const faviconUrl = `${normalizedUrl}/favicon.ico`;
|
|
19
19
|
const iconResponse = await axios.get(faviconUrl, { responseType: 'arraybuffer' });
|
package/src/utils/url.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
const axios = require('axios');
|
|
2
|
+
|
|
3
|
+
async function normalizeUrl(url) {
|
|
2
4
|
if (!url.startsWith('http://') && !url.startsWith('https://')) {
|
|
3
|
-
|
|
5
|
+
try {
|
|
6
|
+
await axios.get('https://' + url);
|
|
7
|
+
url = 'https://' + url;
|
|
8
|
+
} catch (error) {
|
|
9
|
+
url = 'http://' + url;
|
|
10
|
+
}
|
|
4
11
|
}
|
|
5
12
|
return url;
|
|
6
13
|
}
|
|
@@ -17,4 +24,4 @@ function getDomainName(url) {
|
|
|
17
24
|
module.exports = {
|
|
18
25
|
normalizeUrl,
|
|
19
26
|
getDomainName
|
|
20
|
-
};
|
|
27
|
+
};
|