Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions packages/cli/src/commands/config-payments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,20 +142,24 @@ function findMatchingBrace(source: string, open: number): number {
}

function readStringProperty(source: string, key: string): string | undefined {
const match = new RegExp(`${propertyKeyPattern(key)}\\s*:\\s*['"]([^'"]+)['"]`).exec(source);
const match = new RegExp(`${propertyEntryPattern(key)}\\s*:\\s*['"]([^'"]+)['"]`).exec(source);
return match?.[1];
}

function readNumberProperty(source: string, key: string): number | undefined {
const match = new RegExp(`${propertyKeyPattern(key)}\\s*:\\s*(\\d+)\\s*(?=,|})`).exec(source);
const match = new RegExp(`${propertyEntryPattern(key)}\\s*:\\s*(\\d+)\\s*(?=,|})`).exec(source);
return match?.[1] ? Number(match[1]) : undefined;
}

function readBooleanProperty(source: string, key: string): boolean | undefined {
const match = new RegExp(`${propertyKeyPattern(key)}\\s*:\\s*(true|false)`).exec(source);
const match = new RegExp(`${propertyEntryPattern(key)}\\s*:\\s*(true|false)`).exec(source);
return match?.[1] === undefined ? undefined : match[1] === 'true';
}

function propertyEntryPattern(key: string): string {
return `(?:^|[,{\\s])${propertyKeyPattern(key)}`;
}

function propertyKeyPattern(key: string): string {
return `['"]?${escapeRegExp(key)}['"]?`;
}
Expand Down
21 changes: 21 additions & 0 deletions packages/cli/src/commands/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,25 @@ describe('parsePaymentsSummary', () => {

expect(summary?.platformFeeBps).toBeUndefined();
});

it('does not treat longer config property names as provider fields', () => {
const summary = parsePaymentsSummary(`
export default defineConfig({
payments: {
defaultProvider: 'coinpay',
providers: {
coinpay: {
config: { reuse: 'payment-wrong', notenabled: false },
use: 'payment-coinpay',
enabled: true,
},
},
},
});
`);

expect(summary?.providers).toEqual([
{ key: 'coinpay', use: 'payment-coinpay', enabled: true, isDefault: true },
]);
});
});
Loading