forked from Kong/httpsnippet
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathutils.ts
More file actions
24 lines (19 loc) · 764 Bytes
/
utils.ts
File metadata and controls
24 lines (19 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import type { ClientId, ClientInfo, TargetId, TargetInfo } from '../targets/index.js';
import { targets } from '../targets/index.js';
export interface AvailableTarget extends TargetInfo {
clients: ClientInfo[];
}
export const availableTargets = (): AvailableTarget[] =>
Object.keys(targets).map<AvailableTarget>(targetId => ({
...targets[targetId as TargetId].info,
clients: Object.keys(targets[targetId as TargetId].clientsById).map(
clientId => targets[targetId as TargetId].clientsById[clientId].info,
),
}));
export const extname = (targetId: TargetId, clientId: ClientId): '' | `.${string}` => {
const target = targets[targetId];
if (!target) {
return '';
}
return target.clientsById[clientId]?.info.extname || '';
};