Skip to content

Commit b99756e

Browse files
committed
encode string for pUrl
1 parent fde92ac commit b99756e

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

Diff for: dist/index.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/licenses.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import spdxSatisfies from 'spdx-satisfies'
2-
import {Change, Changes} from './schemas'
3-
import {isSPDXValid, octokitClient} from './utils'
4-
import {PackageURL} from 'packageurl-js'
2+
import { Change, Changes } from './schemas'
3+
import { isSPDXValid, octokitClient } from './utils'
4+
import { PackageURL } from 'packageurl-js'
55

66
/**
77
* Loops through a list of changes, filtering and returning the
@@ -29,10 +29,10 @@ export async function getInvalidLicenseChanges(
2929
licenseExclusions?: string[]
3030
}
3131
): Promise<InvalidLicenseChanges> {
32-
const {allow, deny} = licenses
32+
const { allow, deny } = licenses
3333
const licenseExclusions = licenses.licenseExclusions?.map(
3434
(pkgUrl: string) => {
35-
return PackageURL.fromString(pkgUrl)
35+
return PackageURL.fromString(encodeURI(pkgUrl))
3636
}
3737
)
3838

@@ -45,7 +45,9 @@ export async function getInvalidLicenseChanges(
4545
return true
4646
}
4747

48-
const changeAsPackageURL = PackageURL.fromString(change.package_url)
48+
const changeAsPackageURL = PackageURL.fromString(
49+
encodeURI(change.package_url)
50+
)
4951

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

128-
const parseGitHubURL = (url: string): {owner: string; repo: string} | null => {
130+
const parseGitHubURL = (url: string): { owner: string; repo: string } | null => {
129131
try {
130132
const parsed = new URL(url)
131133
if (parsed.host !== 'github.com') {
@@ -135,7 +137,7 @@ const parseGitHubURL = (url: string): {owner: string; repo: string} | null => {
135137
if (components.length < 3) {
136138
return null
137139
}
138-
return {owner: components[1], repo: components[2]}
140+
return { owner: components[1], repo: components[2] }
139141
} catch (_) {
140142
return null
141143
}

0 commit comments

Comments
 (0)