Skip to content

Commit 036c02d

Browse files
authored
Restore hyphenated SOT-23 aliases (#762)
1 parent 750e76f commit 036c02d

6 files changed

Lines changed: 32 additions & 0 deletions

File tree

src/footprinter.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,9 @@ const normalizeDefinition = (def: string): string => {
560560
.replace(/^to-263(?:-(\d+))?(?=_|$)/i, (_, pins) =>
561561
pins ? `to263_${pins}` : "to263",
562562
)
563+
.replace(/^sot-23(?:-(\d+))?(?=_|$)/i, (_, pins) =>
564+
pins ? `sot23_${pins}` : "sot23",
565+
)
563566
.replace(/^sot23-(\d+)(?=_|$)/i, "sot23_$1")
564567
.replace(/^sot-223-(\d+)(?=_|$)/i, "sot223_$1")
565568
.replace(/^to-220f-(\d+)(?=_|$)/i, "to220f_$1")
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

tests/sot23.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,31 @@ test("sot23", () => {
77
const svgContent = convertCircuitJsonToPcbSvg(circuitJson)
88
expect(svgContent).toMatchSvgSnapshot(import.meta.path, "sot23")
99
})
10+
11+
test("sot-23 legacy alias", () => {
12+
const circuitJson = fp.string("sot-23").circuitJson()
13+
expect(circuitJson).toEqual(fp.string("sot23").circuitJson())
14+
15+
const svgContent = convertCircuitJsonToPcbSvg(circuitJson)
16+
expect(svgContent).toMatchSvgSnapshot(import.meta.path, "sot23_legacy_alias")
17+
})
18+
19+
test("sot-23 pin-count aliases", () => {
20+
const aliases = [
21+
["sot-23-3", "sot23_3"],
22+
["sot-23-5", "sot23_5"],
23+
["sot-23-6", "sot23_6"],
24+
] as const
25+
26+
for (const [alias, canonical] of aliases) {
27+
const circuitJson = fp.string(alias).circuitJson()
28+
expect(circuitJson).toEqual(fp.string(canonical).circuitJson())
29+
30+
const svgContent = convertCircuitJsonToPcbSvg(circuitJson)
31+
expect(svgContent).toMatchSvgSnapshot(import.meta.path, alias)
32+
}
33+
})
34+
1035
test("sot23_w3_h1.5_p0.95mm", () => {
1136
const circuitJson = fp.string("sot23_w3_h1.5_p0.95mm").circuitJson()
1237
const svgContent = convertCircuitJsonToPcbSvg(circuitJson)

0 commit comments

Comments
 (0)