@modelriver/cli 1.2.0 → 1.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modelriver/cli",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "ModelRiver CLI for testing webhooks and WebSockets from production",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/index.js CHANGED
@@ -12,10 +12,12 @@ const config = require('./lib/config');
12
12
 
13
13
  const program = new Command();
14
14
 
15
+ const { version } = require('../package.json');
16
+
15
17
  program
16
18
  .name('modelriver')
17
19
  .description('ModelRiver CLI for testing webhooks and WebSockets from production')
18
- .version('1.1.0');
20
+ .version(version);
19
21
 
20
22
  // Global options
21
23
  program
@@ -10,6 +10,11 @@
10
10
  function normalizeWebhookUrl(url) {
11
11
  if (!url) return url;
12
12
 
13
+ // Ensure protocol
14
+ if (!url.match(/^https?:\/\//)) {
15
+ url = 'http://' + url;
16
+ }
17
+
13
18
  try {
14
19
  const urlObj = new URL(url);
15
20
  let pathname = urlObj.pathname;
@@ -98,6 +103,12 @@ function isValidApiKeyFormat(apiKey) {
98
103
  */
99
104
  function parseForwardUrl(url) {
100
105
  if (!url) return null;
106
+
107
+ // Ensure protocol
108
+ if (!url.match(/^https?:\/\//)) {
109
+ url = 'http://' + url;
110
+ }
111
+
101
112
  try {
102
113
  const urlObj = new URL(url);
103
114
  return {
@@ -126,9 +126,19 @@ describe('URL Helpers', () => {
126
126
  expect(parseForwardUrl(undefined)).toBeNull();
127
127
  });
128
128
 
129
+ it('should handle URLs without protocol by defaulting to http', () => {
130
+ const result = parseForwardUrl('myserver:4000/webhook/modelriver');
131
+ expect(result).toEqual({
132
+ hostname: 'myserver',
133
+ port: 4000,
134
+ path: '/webhook/modelriver',
135
+ protocol: 'http'
136
+ });
137
+ });
138
+
129
139
  it('should return null for invalid URLs', () => {
130
- expect(parseForwardUrl('not-a-url')).toBeNull();
131
- expect(parseForwardUrl('just-text')).toBeNull();
140
+ expect(parseForwardUrl('http://invalid url with spaces')).toBeNull();
141
+ expect(parseForwardUrl('just text with spaces')).toBeNull();
132
142
  });
133
143
  });
134
144
  });