Skip to content

Commit

Permalink
encode string for pUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
theztefan committed Nov 13, 2023
1 parent fde92ac commit b99756e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

18 changes: 10 additions & 8 deletions src/licenses.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import spdxSatisfies from 'spdx-satisfies'
import {Change, Changes} from './schemas'
import {isSPDXValid, octokitClient} from './utils'
import {PackageURL} from 'packageurl-js'
import { Change, Changes } from './schemas'
import { isSPDXValid, octokitClient } from './utils'
import { PackageURL } from 'packageurl-js'

/**
* Loops through a list of changes, filtering and returning the
Expand Down Expand Up @@ -29,10 +29,10 @@ export async function getInvalidLicenseChanges(
licenseExclusions?: string[]
}
): Promise<InvalidLicenseChanges> {
const {allow, deny} = licenses
const { allow, deny } = licenses
const licenseExclusions = licenses.licenseExclusions?.map(
(pkgUrl: string) => {
return PackageURL.fromString(pkgUrl)
return PackageURL.fromString(encodeURI(pkgUrl))
}
)

Expand All @@ -45,7 +45,9 @@ export async function getInvalidLicenseChanges(
return true
}

const changeAsPackageURL = PackageURL.fromString(change.package_url)
const changeAsPackageURL = PackageURL.fromString(
encodeURI(change.package_url)
)

// We want to find if the licenseExclussion list contains the PackageURL of the Change
// If it does, we want to filter it out and therefore return false
Expand Down Expand Up @@ -125,7 +127,7 @@ const fetchGHLicense = async (
}
}

const parseGitHubURL = (url: string): {owner: string; repo: string} | null => {
const parseGitHubURL = (url: string): { owner: string; repo: string } | null => {
try {
const parsed = new URL(url)
if (parsed.host !== 'github.com') {
Expand All @@ -135,7 +137,7 @@ const parseGitHubURL = (url: string): {owner: string; repo: string} | null => {
if (components.length < 3) {
return null
}
return {owner: components[1], repo: components[2]}
return { owner: components[1], repo: components[2] }
} catch (_) {
return null
}
Expand Down

0 comments on commit b99756e

Please sign in to comment.