new-github-issue-url
Advanced tools
Comparing version 0.1.0 to 0.1.1
11
index.js
'use strict'; | ||
module.exports = (options = {}) => { | ||
if (!(options.user && options.repo)) { | ||
throw new Error('The `user` and `repo` options are required'); | ||
let repoUrl = 'https://github.com/'; | ||
if (options.repoUrl) { | ||
repoUrl += options.repoUrl; | ||
} else if (options.user && options.repo) { | ||
repoUrl += `${options.user}/${options.repo}`; | ||
} else { | ||
throw new Error('You need to specify either the `repoUrl` option or both the `user` and `repo` options'); | ||
} | ||
const url = new URL(`https://github.com/${options.user}/${options.repo}/issues/new`); | ||
const url = new URL(`${repoUrl}/issues/new`); | ||
@@ -10,0 +15,0 @@ const types = [ |
{ | ||
"name": "new-github-issue-url", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Generate a URL for opening a new GitHub issue with prefilled title, body, and other fields", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -53,5 +53,12 @@ # new-github-issue-url [](https://travis-ci.com/sindresorhus/new-github-issue-url) | ||
You are required to either specify the `repoUrl` option or both the `user` and `repo` options. | ||
##### repoUrl | ||
Type: `string` | ||
The full URL to the repo. | ||
##### user | ||
*Required*<br> | ||
Type: `string` | ||
@@ -63,3 +70,2 @@ | ||
*Required*<br> | ||
Type: `string` | ||
@@ -66,0 +72,0 @@ |
5339
35
131