Skip to content

Commit b1a1404

Browse files
committed
fix: fixes a bug in path for infoLicense func
1 parent 90224ce commit b1a1404

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

spectral/src/functions/infoLicenseApache2.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,22 @@ export default (targetVal: any, _: any, context: any): IFunctionResult[] => {
1515

1616
const results: IFunctionResult[] = [];
1717
const expectName = 'Apache 2.0'
18-
p = context.path[1];
18+
if (context.path[1] != undefined) {
19+
p = context.path[1];
20+
}
1921
if (targetVal?.name != expectName) {
2022
results.push({
2123
message: '`name` must be "' + expectName + '"',
22-
path: [...p, 'license']
24+
path: p
2325
})
24-
}
26+
}
2527
const expectUrl = 'https://www.apache.org/licenses/LICENSE-2.0';
2628
if (targetVal?.url !== expectUrl) {
2729
results.push({
2830
message: '`url` must be "' + expectUrl + '" not "' + targetVal?.url + '"',
29-
path: [...p, 'license']
31+
path: p
3032
})
31-
}
33+
}
3234

3335
return results
3436
}

0 commit comments

Comments
 (0)