experiments in a post-browser web
10
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(cmd): support scheme-less URLs with paths in open command

Update getValidURL in both open.js files to:
- Add optional path pattern (\/.*)?$ to domain regex so URLs like
"google.com/maps" are recognized
- Add localhost pattern with optional port and path support

The panel.js files already had this fix, but the open.js command
validators were rejecting URLs with paths because the regex ended
at the TLD without allowing a path component.

+15 -9
+9 -6
app/cmd/commands/open.js
··· 64 64 function getValidURL(str) { 65 65 // Quick check for empty string 66 66 if (!str) return { valid: false }; 67 - 67 + 68 68 // Check if it starts with a valid protocol 69 69 const hasValidProtocol = /^(https?|ftp|file|peek):\/\//.test(str); 70 - 70 + 71 71 if (!hasValidProtocol) { 72 - // If no protocol, check if it's a domain name pattern 73 - const isDomainPattern = /^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/.test(str); 74 - if (isDomainPattern) { 72 + // Check if it looks like a domain (e.g., "example.com", "example.com/path", "localhost") 73 + // Pattern: domain.tld or domain.tld/path (with optional port for localhost) 74 + const isDomainPattern = /^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(\/.*)?$/.test(str); 75 + const isLocalhost = /^localhost(:\d+)?(\/.*)?$/.test(str); 76 + 77 + if (isDomainPattern || isLocalhost) { 75 78 // It's a domain without protocol, add https:// 76 79 const urlWithProtocol = 'https://' + str; 77 80 try { ··· 84 87 } 85 88 return { valid: false }; 86 89 } 87 - 90 + 88 91 try { 89 92 // Already has protocol, just validate 90 93 new URL(str);
+6 -3
extensions/cmd/commands/open.js
··· 69 69 const hasValidProtocol = /^(https?|ftp|file|peek):\/\//.test(str); 70 70 71 71 if (!hasValidProtocol) { 72 - // If no protocol, check if it's a domain name pattern 73 - const isDomainPattern = /^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/.test(str); 74 - if (isDomainPattern) { 72 + // Check if it looks like a domain (e.g., "example.com", "example.com/path", "localhost") 73 + // Pattern: domain.tld or domain.tld/path (with optional port for localhost) 74 + const isDomainPattern = /^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(\/.*)?$/.test(str); 75 + const isLocalhost = /^localhost(:\d+)?(\/.*)?$/.test(str); 76 + 77 + if (isDomainPattern || isLocalhost) { 75 78 // It's a domain without protocol, add https:// 76 79 const urlWithProtocol = 'https://' + str; 77 80 try {