Skip to content

Commit bcf3455

Browse files
Merge remote-tracking branch 'upstream/main' into feat/package-health-score
# Conflicts: # i18n/locales/ar-EG.json # i18n/locales/fr-FR.json
2 parents 60833c7 + b3da028 commit bcf3455

File tree

10 files changed

+2000
-1971
lines changed

10 files changed

+2000
-1971
lines changed

app/components/Compare/FacetBarChart.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ const config = computed<VueUiHorizontalBarConfig>(() => {
131131
csv: false,
132132
altCopy: true,
133133
},
134-
buttonTitle: {
134+
buttonTitles: {
135135
img: $t('package.trends.download_file', { fileType: 'PNG' }),
136136
svg: $t('package.trends.download_file', { fileType: 'SVG' }),
137137
altCopy: $t('package.trends.copy_alt.button_label'),

app/components/Package/HealthScore.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<script setup lang="ts">
1+
<script setup lang="ts">
22
interface HealthScoreDimension {
33
score: number
44
weight: number
@@ -58,13 +58,13 @@ function scoreBarColor(score: number): string {
5858
}
5959
6060
const dimensions = computed(() => {
61-
if (!data.value) return []
61+
if (!data.value?.dimensions) return []
6262
const d = data.value.dimensions
6363
return [
64-
{ key: 'maintenance', label: $t('package.health_score.dimension_maintenance'), score: d.maintenance.score, weight: d.maintenance.weight },
65-
{ key: 'quality', label: $t('package.health_score.dimension_quality'), score: d.quality.score, weight: d.quality.weight },
66-
{ key: 'security', label: $t('package.health_score.dimension_security'), score: d.security.score, weight: d.security.weight },
67-
{ key: 'popularity', label: $t('package.health_score.dimension_popularity'), score: d.popularity.score, weight: d.popularity.weight },
64+
{ key: 'maintenance', label: $t('package.health_score.dimension_maintenance'), score: d.maintenance?.score ?? 0, weight: d.maintenance?.weight ?? 0 },
65+
{ key: 'quality', label: $t('package.health_score.dimension_quality'), score: d.quality?.score ?? 0, weight: d.quality?.weight ?? 0 },
66+
{ key: 'security', label: $t('package.health_score.dimension_security'), score: d.security?.score ?? 0, weight: d.security?.weight ?? 0 },
67+
{ key: 'popularity', label: $t('package.health_score.dimension_popularity'), score: d.popularity?.score ?? 0, weight: d.popularity?.weight ?? 0 },
6868
]
6969
})
7070
</script>
@@ -147,7 +147,7 @@ const dimensions = computed(() => {
147147

148148
<!-- Footer link -->
149149
<a
150-
:href="`https://npm-pulse.vercel.app/api/v1/score/${packageName}`"
150+
:href="`https://npm-pulse.vercel.app/api/v1/score/${props.packageName}`"
151151
target="_blank"
152152
rel="noopener noreferrer"
153153
class="inline-flex items-center gap-1 text-xs text-fg-subtle hover:text-fg transition-colors duration-150 underline underline-offset-2 decoration-fg-subtle/40"

app/pages/package/[[org]]/[name].vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<script setup lang="ts">
1+
<script setup lang="ts">
22
import { assertValidPackageName } from '#shared/utils/npm'
33
import { getDependencyCount } from '~/utils/npm/dependency-count'
44

i18n/locales/ar-EG.json

Lines changed: 456 additions & 456 deletions
Large diffs are not rendered by default.

i18n/locales/fr-FR.json

Lines changed: 1504 additions & 1504 deletions
Large diffs are not rendered by default.

modules/security-headers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export default defineNuxtModule({
3535
'https://registry.npmjs.org',
3636
'https://api.npmjs.org',
3737
'https://npm.antfu.dev',
38+
'https://npm-pulse.vercel.app',
3839
BLUESKY_API,
3940
...ALL_KNOWN_GIT_API_ORIGINS,
4041
// Local CLI connector (npmx CLI communicates via localhost)

server/utils/parse-package-params.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ export function parsePackageParams(segments: string[]): {
66
rawPackageName: string
77
rawVersion: string | undefined
88
} {
9-
const vIndex = segments.indexOf('v')
9+
let vIndex = segments.indexOf('v')
10+
11+
// If we encounter ".../v/v/...", treat the second "v" as the version delimiter.
12+
if (segments[vIndex] === 'v' && segments[vIndex + 1] === 'v') {
13+
vIndex++
14+
}
1015

1116
if (vIndex !== -1 && vIndex < segments.length - 1) {
1217
return {

shared/utils/parse-package-param.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ export interface ParsedPackageParams {
3737
*/
3838
export function parsePackageParam(pkgParam: string): ParsedPackageParams {
3939
const segments = pkgParam.split('/')
40-
const vIndex = segments.indexOf('v')
40+
let vIndex = segments.indexOf('v')
41+
42+
// If we encounter ".../v/v/...", treat the second "v" as the version delimiter.
43+
if (segments[vIndex] === 'v' && segments[vIndex + 1] === 'v') {
44+
vIndex++
45+
}
4146

4247
if (vIndex !== -1 && vIndex < segments.length - 1) {
4348
return {

test/unit/server/utils/parse-package-params.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,14 @@ describe('parsePackageParams', () => {
4949
rawVersion: '1.0.0',
5050
})
5151
})
52+
53+
it('parses scoped package names whose package segment is literally v', () => {
54+
const segments = ['@scope', 'v', 'v', '1.2.3']
55+
const result = parsePackageParams(segments)
56+
expect(result).toEqual({
57+
rawPackageName: '@scope/v',
58+
rawVersion: '1.2.3',
59+
})
60+
})
5261
})
5362
})

test/unit/shared/utils/parse-package-param.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@ describe('parsePackageParam', () => {
8585
rest: [],
8686
})
8787
})
88+
89+
it('parses scoped package names whose package segment is literally v', () => {
90+
const result = parsePackageParam('@scope/v/v/1.2.3/dist/index.js')
91+
expect(result).toEqual({
92+
packageName: '@scope/v',
93+
version: '1.2.3',
94+
rest: ['dist', 'index.js'],
95+
})
96+
})
8897
})
8998

9099
describe('edge cases', () => {

0 commit comments

Comments
 (0)