Theme system refactor (#31)

This commit is contained in:
Gregory Schier
2024-05-21 17:56:06 -07:00
committed by GitHub
parent 8606940dee
commit 83aaeb94f6
82 changed files with 909 additions and 739 deletions

View File

@@ -7,12 +7,14 @@ export function fallbackRequestName(r: HttpRequest | GrpcRequest | null): string
return r.name;
}
const withoutVariables = r.url.replace(/\$\{\[[^\]]+]}/g, '');
const withoutVariables = r.url.replace(/\$\{\[\s*([^\]]+)\s*]}/g, '$1');
if (withoutVariables.trim() === '') {
return r.model === 'http_request' ? 'New HTTP Request' : 'new gRPC Request';
}
const fixedUrl = r.url.match(/^https?:\/\//) ? r.url : 'http://' + r.url;
const fixedUrl = withoutVariables.match(/^https?:\/\//)
? withoutVariables
: 'http://' + withoutVariables;
if (r.model === 'grpc_request' && r.service != null && r.method != null) {
const shortService = r.service.split('.').pop();
@@ -21,6 +23,7 @@ export function fallbackRequestName(r: HttpRequest | GrpcRequest | null): string
try {
const url = new URL(fixedUrl);
const pathname = url.pathname === '/' ? '' : url.pathname;
console.log('hello', fixedUrl);
return `${url.host}${pathname}`;
} catch (_) {
// Nothing