u2a 3.5.5 → 3.5.6

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "u2a",
3
- "version": "3.5.5",
3
+ "version": "3.5.6",
4
4
  "description": "URL to App - Turn any URL into a desktop application",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -8,7 +8,9 @@
8
8
  },
9
9
  "scripts": {
10
10
  "start": "node src/index.js",
11
- "postinstall": "node src/utils/postinstall.js"
11
+ "postinstall": "node src/utils/postinstall.js",
12
+ "test": "jest",
13
+ "wta": "jest --watchAll --verbose"
12
14
  },
13
15
  "keywords": [
14
16
  "cli",
@@ -28,10 +30,13 @@
28
30
  "electron": "^22.0.0",
29
31
  "icojs": "^0.19.5",
30
32
  "inquirer": "^8.2.5",
33
+ "is-admin": "^3.0.0",
31
34
  "open": "^8.4.0",
32
35
  "png-to-ico": "^2.1.8",
33
- "sharp": "^0.33.5",
34
- "is-admin": "^3.0.0"
36
+ "sharp": "^0.33.5"
37
+ },
38
+ "devDependencies": {
39
+ "jest": "^29.7.0"
35
40
  },
36
41
  "homepage": "https://urltoapp.xyz",
37
42
  "repository": {
@@ -2,6 +2,7 @@ const fs = require('fs');
2
2
  const path = require('path');
3
3
  const os = require('os');
4
4
 
5
+
5
6
  const CONFIG_DIR = path.join(os.homedir(), '.u2a');
6
7
  const APPS_DIR = path.join(CONFIG_DIR, 'apps');
7
8
  const LOGS_DIR = path.join(CONFIG_DIR, 'logs');
@@ -34,11 +35,10 @@ function writeDB(data) {
34
35
  fs.writeFileSync(DB_PATH, JSON.stringify(data, null, 2));
35
36
  }
36
37
 
37
- function addAppToDB(domain, appData) {
38
+ function addAppToDB(appName, appData) {
38
39
  const db = readDB();
39
- db[domain] = appData;
40
+ db[appName] = appData;
40
41
  writeDB(db);
41
- logger.debug(`Application recorded in the database:`, domain);
42
42
  }
43
43
 
44
44
  module.exports = {
@@ -77,4 +77,4 @@ class Logger {
77
77
  }
78
78
  }
79
79
 
80
- module.exports = Logger;
80
+ module.exports = Logger;
@@ -22,7 +22,7 @@ function initSettings(reset = false) {
22
22
  currentSettings = JSON.parse(fs.readFileSync(SETTINGS_PATH, 'utf8'));
23
23
  logger.debug('Existing settings loaded');
24
24
  } catch (err) {
25
- logger.debug(`Error reading existing settings.json, will reinitialize`, err.message);
25
+ logger.debug(`Error reading existing settings.json, will reset`, err.message);
26
26
  currentSettings = {};
27
27
  }
28
28
  }
package/src/utils/url.js CHANGED
@@ -2,15 +2,18 @@ const axios = require('axios');
2
2
  const { sanitizeInput } = require('./sanitize');
3
3
 
4
4
  async function normalizeUrl(url) {
5
- if (!url.startsWith('http://') && !url.startsWith('https://')) {
6
- try {
7
- await axios.get('https://' + url);
8
- url = 'https://' + url;
9
- } catch (error) {
10
- url = 'http://' + url;
11
- }
5
+ const sanitizedUrl = sanitizeInput(url);
6
+
7
+ if (sanitizedUrl.startsWith('http://') || sanitizedUrl.startsWith('https://')) {
8
+ return sanitizedUrl;
9
+ }
10
+
11
+ try {
12
+ await axios.get('https://' + sanitizedUrl);
13
+ return 'https://' + sanitizedUrl;
14
+ } catch (error) {
15
+ return 'http://' + sanitizedUrl;
12
16
  }
13
- return sanitizeInput(url);
14
17
  }
15
18
 
16
19
  function getDomainName(url) {
@@ -25,4 +28,4 @@ function getDomainName(url) {
25
28
  module.exports = {
26
29
  normalizeUrl,
27
30
  getDomainName
28
- };
31
+ };
@@ -1,22 +0,0 @@
1
- name: Node.js Package
2
-
3
- on:
4
- push:
5
- paths:
6
- - 'package.json'
7
- branches:
8
- - main
9
-
10
- jobs:
11
-
12
- publish-npm:
13
- runs-on: ubuntu-latest
14
- steps:
15
- - uses: actions/checkout@v4
16
- - uses: actions/setup-node@v4
17
- with:
18
- node-version: 20
19
- registry-url: https://registry.npmjs.org/
20
- - run: npm publish
21
- env:
22
- NODE_AUTH_TOKEN: ${{ secrets.npm_token }}