encode string for pUrl
This commit is contained in:
+2
-2
@@ -351,7 +351,7 @@ function getInvalidLicenseChanges(changes, licenses) {
|
|||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const { allow, deny } = licenses;
|
const { allow, deny } = licenses;
|
||||||
const licenseExclusions = (_a = licenses.licenseExclusions) === null || _a === void 0 ? void 0 : _a.map((pkgUrl) => {
|
const licenseExclusions = (_a = licenses.licenseExclusions) === null || _a === void 0 ? void 0 : _a.map((pkgUrl) => {
|
||||||
return packageurl_js_1.PackageURL.fromString(pkgUrl);
|
return packageurl_js_1.PackageURL.fromString(encodeURI(pkgUrl));
|
||||||
});
|
});
|
||||||
const groupedChanges = yield groupChanges(changes);
|
const groupedChanges = yield groupChanges(changes);
|
||||||
// Takes the changes from the groupedChanges object and filters out the ones that are part of the exclusions list
|
// Takes the changes from the groupedChanges object and filters out the ones that are part of the exclusions list
|
||||||
@@ -360,7 +360,7 @@ function getInvalidLicenseChanges(changes, licenses) {
|
|||||||
if (change.package_url.length === 0) {
|
if (change.package_url.length === 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const changeAsPackageURL = packageurl_js_1.PackageURL.fromString(change.package_url);
|
const changeAsPackageURL = packageurl_js_1.PackageURL.fromString(encodeURI(change.package_url));
|
||||||
// We want to find if the licenseExclussion list contains the PackageURL of the Change
|
// 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
|
// If it does, we want to filter it out and therefore return false
|
||||||
// If it doesn't, we want to keep it and therefore return true
|
// If it doesn't, we want to keep it and therefore return true
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
+10
-8
@@ -1,7 +1,7 @@
|
|||||||
import spdxSatisfies from 'spdx-satisfies'
|
import spdxSatisfies from 'spdx-satisfies'
|
||||||
import {Change, Changes} from './schemas'
|
import { Change, Changes } from './schemas'
|
||||||
import {isSPDXValid, octokitClient} from './utils'
|
import { isSPDXValid, octokitClient } from './utils'
|
||||||
import {PackageURL} from 'packageurl-js'
|
import { PackageURL } from 'packageurl-js'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loops through a list of changes, filtering and returning the
|
* Loops through a list of changes, filtering and returning the
|
||||||
@@ -29,10 +29,10 @@ export async function getInvalidLicenseChanges(
|
|||||||
licenseExclusions?: string[]
|
licenseExclusions?: string[]
|
||||||
}
|
}
|
||||||
): Promise<InvalidLicenseChanges> {
|
): Promise<InvalidLicenseChanges> {
|
||||||
const {allow, deny} = licenses
|
const { allow, deny } = licenses
|
||||||
const licenseExclusions = licenses.licenseExclusions?.map(
|
const licenseExclusions = licenses.licenseExclusions?.map(
|
||||||
(pkgUrl: string) => {
|
(pkgUrl: string) => {
|
||||||
return PackageURL.fromString(pkgUrl)
|
return PackageURL.fromString(encodeURI(pkgUrl))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -45,7 +45,9 @@ export async function getInvalidLicenseChanges(
|
|||||||
return true
|
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
|
// 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
|
// If it does, we want to filter it out and therefore return false
|
||||||
@@ -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 {
|
try {
|
||||||
const parsed = new URL(url)
|
const parsed = new URL(url)
|
||||||
if (parsed.host !== 'github.com') {
|
if (parsed.host !== 'github.com') {
|
||||||
@@ -135,7 +137,7 @@ const parseGitHubURL = (url: string): {owner: string; repo: string} | null => {
|
|||||||
if (components.length < 3) {
|
if (components.length < 3) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
return {owner: components[1], repo: components[2]}
|
return { owner: components[1], repo: components[2] }
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user