File tree Expand file tree Collapse file tree 4 files changed +29
-7
lines changed
Expand file tree Collapse file tree 4 files changed +29
-7
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,9 @@ export class HomeView {
2828 const repoName = utils . getGithubRepositoryPath (
2929 utils . parseRepositoryUrl ( repository )
3030 )
31+ if ( repoName === null ) {
32+ return ;
33+ }
3134
3235 fetchScorecardData ( repoName ) . then ( ( data ) => {
3336 if ( data !== null ) {
Original file line number Diff line number Diff line change @@ -24,6 +24,9 @@ export class Scorecard {
2424 }
2525
2626 const repoName = utils . getGithubRepositoryPath ( githubURL . href ) ;
27+ if ( repoName === null ) {
28+ return ;
29+ }
2730 const pannel = clone . getElementById ( "pan-scorecard" ) ;
2831 fetchScorecardData ( repoName ) . then ( ( data ) => {
2932 if ( ! data ) {
Original file line number Diff line number Diff line change @@ -4,12 +4,17 @@ import avatarURL from "../img/avatar-default.png";
44window . activeLegendElement = null ;
55
66export function getGithubRepositoryPath ( url ) {
7- const github = new URL ( url ) ;
7+ try {
8+ const github = new URL ( url ) ;
89
9- return github . pathname . slice (
10- 1 ,
11- github . pathname . includes ( ".git" ) ? - 4 : github . pathname . length
12- ) ;
10+ return github . pathname . slice (
11+ 1 ,
12+ github . pathname . includes ( ".git" ) ? - 4 : github . pathname . length
13+ ) ;
14+ }
15+ catch {
16+ return null ;
17+ }
1318}
1419
1520/**
Original file line number Diff line number Diff line change @@ -4,9 +4,20 @@ import path from "node:path";
44// Import Internal Dependencies
55import { buildServer } from "../http-server/index.js" ;
66
7- export async function start ( json = "nsecure-result.json" , options = { } ) {
7+ export async function start (
8+ payloadFileBasename = "nsecure-result.json" ,
9+ options = { }
10+ ) {
811 const port = Number ( options . port ) ;
9- const dataFilePath = path . join ( process . cwd ( ) , json ) ;
12+ const fileExtension = path . extname ( payloadFileBasename ) ;
13+ if ( fileExtension !== ".json" && fileExtension !== "" ) {
14+ throw new Error ( "You must provide a JSON file (scanner payload) to open" ) ;
15+ }
16+
17+ const dataFilePath = path . join (
18+ process . cwd ( ) ,
19+ fileExtension === "" ? `${ payloadFileBasename } .json` : payloadFileBasename
20+ ) ;
1021
1122 const httpServer = buildServer ( dataFilePath , {
1223 port : Number . isNaN ( port ) ? 0 : port
You can’t perform that action at this time.
0 commit comments