File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -47,8 +47,20 @@ const readPackageJson = async () => {
47
47
const { repository, name } = JSON . parse ( await fs . readFile ( 'package.json' , 'utf8' ) ) ;
48
48
49
49
const [ prefix , repo ] = repository ?. split ( ':' ) || [ ] ;
50
- const repoUrl = ( prefix === 'github' && repo ) ? `https://github.com/${ repo } ` : 'Invalid GitHub string format' ;
50
+ let repoUrl ;
51
+ if ( prefix === 'github' && repo ) {
52
+ // Check if the repository name ends with '.git' and remove it
53
+ const sanitizedRepo = repo . endsWith ( '.git' ) ? repo . slice ( 0 , - 4 ) : repo ;
51
54
55
+ // Construct the GitHub URL
56
+ repoUrl = `https://github.com/${ sanitizedRepo } ` ;
57
+ } else {
58
+ // Handle the case of an invalid GitHub string format
59
+ console . error ( 'Invalid GitHub string format. Please provide a valid GitHub repository string in the format "github:username/repo.git".' ) ;
60
+
61
+ // Optionally, set repoUrl to a default value or handle the error accordingly
62
+ repoUrl = undefined ;
63
+ }
52
64
return { projectName : name || "" , repoUrl } ;
53
65
} catch ( error ) {
54
66
console . error ( 'Error reading or parsing package.json file:' , error ) ;
You can’t perform that action at this time.
0 commit comments