Skip to content

Commit

Permalink
Don't transform homepage URL
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Skelton committed Dec 23, 2022
1 parent a22a2ca commit 136a1e1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bundles/@yarnpkg/plugin-outdated.js

Large diffs are not rendered by default.

18 changes: 11 additions & 7 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ export const truthy = Boolean as unknown as <T>(
) => arg is T

export function getHomepageURL({ raw: manifest }: Manifest): string | null {
// Prefer the homepage over the repository URL
if (manifest.homepage) {
return manifest.homepage
}

const repo = manifest.repository
const repoURL = manifest.homepage
? manifest.homepage
: typeof repo === "string"
? repo
: typeof repo === "object" && typeof repo.url === "string"
? repo.url
: null
const repoURL =
typeof repo === "string"
? repo
: typeof repo === "object" && typeof repo.url === "string"
? repo.url
: null

const info = repoURL ? fromUrl(repoURL) : undefined
const commitish = info?.committish ? `#${info.committish}` : ""
Expand Down
6 changes: 6 additions & 0 deletions test/specs/url.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ test.describe("yarn outdated --url", () => {
expect(
getURL({ homepage: "http://foo.com", repository: "http://bar.com" })
).toBe("http://foo.com")
expect(
getURL({
homepage: "https://github.com/foo/bar/tree/master/packages/a#readme",
repository: "https://github.com/bar/foo",
})
).toBe("https://github.com/foo/bar/tree/master/packages/a#readme")
})

test.describe("when outdatedIncludeURL config is true", () => {
Expand Down

0 comments on commit 136a1e1

Please sign in to comment.