Skip to content
This repository has been archived by the owner on Dec 12, 2023. It is now read-only.

Commit

Permalink
Correct the view API endpoint hits
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed Mar 8, 2016
1 parent 7eb9f8b commit 9692f6c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@ export interface ViewOptions {

export function viewEntry (raw: string, options: ViewOptions = {}) {
return new Promise((resolve) => {
const dependency = parseRegistryRaw(raw, options)
const { meta } = parseRegistryRaw(raw, options)
const path = `entries/${encodeURIComponent(meta.source)}/${encodeURIComponent(meta.name)}`

return resolve(readJsonFrom(dependency.location))
return resolve(readJsonFrom(resolveUrl(rc.registryURL, path)))
})
}

export function viewVersions (raw: string, options: ViewOptions = {}) {
return new Promise((resolve) => {
const { meta } = parseRegistryRaw(raw, options)
let path = `entries/${encodeURIComponent(meta.source)}/${encodeURIComponent(meta.name)}/versions`

if (meta.version) {
path += `/${encodeURIComponent(meta.version)}`
}

return resolve(readJsonFrom(resolveUrl(rc.registryURL, `entries/${encodeURIComponent(meta.source)}/${encodeURIComponent(meta.name)}/versions/${encodeURIComponent(meta.version || '*')}`)))
return resolve(readJsonFrom(resolveUrl(rc.registryURL, path)))
})
}

0 comments on commit 9692f6c

Please sign in to comment.