[READ-ONLY] a fast, modern browser for the npm registry
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: normalise package licence field (#944)

authored by

Wojciech Maj and committed by
GitHub
77f8f81e c9d9c9dd

+19 -10
+7 -1
app/composables/npm/usePackage.ts
··· 69 69 if (pkg.time[v]) filteredTime[v] = pkg.time[v] 70 70 } 71 71 72 + // Normalize license field 73 + let license = pkg.license 74 + if (license && typeof license === 'object' && 'type' in license) { 75 + license = license.type 76 + } 77 + 72 78 return { 73 79 '_id': pkg._id, 74 80 '_rev': pkg._rev, ··· 78 84 'time': filteredTime, 79 85 'maintainers': pkg.maintainers, 80 86 'author': pkg.author, 81 - 'license': pkg.license, 87 + 'license': license, 82 88 'homepage': pkg.homepage, 83 89 'keywords': pkg.keywords, 84 90 'repository': pkg.repository,
+4 -1
app/composables/usePackageComparison.ts
··· 152 152 severity: vulnsSeverity, 153 153 }, 154 154 metadata: { 155 - license: pkgData.license, 155 + license: 156 + typeof pkgData.license === 'object' && 'type' in pkgData.license 157 + ? pkgData.license.type 158 + : pkgData.license, 156 159 // Use version-specific publish time, NOT time.modified (which can be 157 160 // updated by metadata changes like maintainer additions) 158 161 lastUpdated: pkgData.time?.[latestVersion],
+8 -8
shared/types/npm-registry.ts
··· 6 6 * @see https://github.com/npm/registry/blob/main/docs/REGISTRY-API.md 7 7 */ 8 8 9 - import type { PackumentVersion } from '@npm/types' 9 + import type { Packument as PackumentWithoutLicenseObjects, PackumentVersion } from '@npm/types' 10 10 import type { ReadmeResponse } from './readme' 11 11 12 12 // Re-export official npm types for packument/manifest 13 - export type { 14 - Packument, 15 - PackumentVersion, 16 - Manifest, 17 - ManifestVersion, 18 - PackageJSON, 19 - } from '@npm/types' 13 + export type { PackumentVersion, Manifest, ManifestVersion, PackageJSON } from '@npm/types' 14 + 15 + // TODO: Remove this type override when @npm/types fixes the license field typing 16 + export type Packument = Omit<PackumentWithoutLicenseObjects, 'license'> & { 17 + // Fix for license field being incorrectly typed in @npm/types 18 + license?: string | { type: string; url?: string } 19 + } 20 20 21 21 /** Install scripts info (preinstall, install, postinstall) */ 22 22 export interface InstallScriptsInfo {