Skip to content

Commit

Permalink
chore: accept dotted path instead of slashed
Browse files Browse the repository at this point in the history
  • Loading branch information
anatawa12 committed Jun 12, 2024
1 parent 7a22dbc commit f71b6b8
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions services/winget/winget-version.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,18 @@ export default class WingetVersion extends GithubAuthV4Service {

static route = {
base: 'winget/v',
pattern: ':owner/:name',
pattern: ':name',
}

static openApi = {
'/winget/v/{owner}/{name}': {
'/winget/v/{name}': {
get: {
summary: 'WinGet Package Version',
description: 'WinGet Community Repository',
parameters: [
pathParam({
name: 'owner',
example: 'Microsoft',
}),
pathParam({
name: 'name',
example: 'WSL',
example: 'Microsoft.WSL',
}),
],
},
Expand All @@ -53,9 +49,10 @@ export default class WingetVersion extends GithubAuthV4Service {
label: 'winget',
}

async fetch({ owner, name }) {
const ownerFirst = owner[0].toLowerCase()
const path = `manifests/${ownerFirst}/${owner}/${name}`
async fetch({ name }) {
const nameFirstLower = name[0].toLowerCase()
const nameSlashed = name.replaceAll('.', '/')
const path = `manifests/${nameFirstLower}/${nameSlashed}`
const expression = `HEAD:${path}`
return this._requestGraphql({
query: gql`
Expand All @@ -78,9 +75,9 @@ export default class WingetVersion extends GithubAuthV4Service {
})
}

async handle({ owner, name }) {
async handle({ name }) {
try {
const json = await this.fetch({ owner, name })
const json = await this.fetch({ name })
if (json.data.repository.object === null) {
throw new InvalidParameter({
prettyMessage: 'package not found',
Expand Down

0 comments on commit f71b6b8

Please sign in to comment.