Skip to content

Commit 38763e1

Browse files
authored
chore: refactor normalizeLicense
1 parent cbeb9a0 commit 38763e1

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

app/composables/npm/usePackage.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ function getTrustLevel(version: PackumentVersion): PublishTrustLevel {
1717
}
1818

1919
function normalizeLicense(license?: PackumentLicense): string | undefined {
20-
if (license && typeof license === 'object' && 'type' in license) {
21-
return license.type
22-
}
23-
return typeof license === 'string' ? license : undefined
20+
if (!license) return undefined
21+
if (typeof license === 'string') return license
22+
if (typeof license.type === 'string') return license.type
23+
return undefined
2424
}
2525

2626
/**
@@ -116,7 +116,7 @@ export function transformPackument(
116116
}
117117

118118
// Normalize license field
119-
const license = normalizeLicense(versionData?.license || pkg.license)
119+
const license = normalizeLicense(requestedVersion ? versionData?.license : pkg.license)
120120

121121
// Extract storybook field from the requested version (custom package.json field)
122122
const requestedPkgVersion = requestedVersion ? pkg.versions[requestedVersion] : null

0 commit comments

Comments
 (0)