Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check for #<num> in getValidUrlFromInput #373

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/getValidUrlFromInput.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export function getValidUrlFromInput(urlString: string): URL {
if (urlString.includes('#')) {
if (/#\d+/.test(urlString)) {
urlString = urlString.replace('#', '/issues/')
} else if (!urlString.includes('issues')) {
} else if (!/\/issues\/\d+/.test(urlString)) {
SgtPooki marked this conversation as resolved.
Show resolved Hide resolved
throw new Error('Unsupported URL string. URLs should be formatted like a github issue')
}
/**
Expand Down
12 changes: 12 additions & 0 deletions tests/fixtures/getIssueResult/filecoin-station-roadmap-12.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"html_url": "https://github.com/filecoin-station/roadmap/issues/12",
"title": "Station Core alpha release",
"state": "closed",
"node_id": "I_kwDOIUF5GM5fK-I3",
"body_html": "<p dir=\"auto\">ETA: 2023-04-01</p>\n<p dir=\"auto\">Description: Develop a functional but rudimentary <code class=\"notranslate\">Station Core</code> (ex <code class=\"notranslate\">Station headless</code>) binary for early adopters.</p>\n<p dir=\"auto\">Children:</p>\n<ul class=\"contains-task-list\">\n<li class=\"task-list-item\"><input type=\"checkbox\" id=\"\" disabled=\"\" class=\"task-list-item-checkbox\" checked=\"\"> Bundled Modules\n<ul dir=\"auto\">\n<li><a class=\"issue-link js-issue-link\" data-error-text=\"Failed to load title\" data-id=\"1597333712\" data-permission-text=\"Title is private\" data-url=\"https://github.com/filecoin-station/core/issues/1\" data-hovercard-type=\"issue\" data-hovercard-url=\"/filecoin-station/core/issues/1/hovercard\" href=\"https://github.com/filecoin-station/core/issues/1\">filecoin-station/core#1</a></li>\n</ul>\n</li>\n<li class=\"task-list-item\"><input type=\"checkbox\" id=\"\" disabled=\"\" class=\"task-list-item-checkbox\" checked=\"\"> CLI\n<ul dir=\"auto\">\n<li><a class=\"issue-link js-issue-link\" data-error-text=\"Failed to load title\" data-id=\"1597336589\" data-permission-text=\"Title is private\" data-url=\"https://github.com/filecoin-station/core/issues/2\" data-hovercard-type=\"issue\" data-hovercard-url=\"/filecoin-station/core/issues/2/hovercard\" href=\"https://github.com/filecoin-station/core/issues/2\">filecoin-station/core#2</a></li>\n<li><a class=\"issue-link js-issue-link\" data-error-text=\"Failed to load title\" data-id=\"1597338046\" data-permission-text=\"Title is private\" data-url=\"https://github.com/filecoin-station/core/issues/3\" data-hovercard-type=\"issue\" data-hovercard-url=\"/filecoin-station/core/issues/3/hovercard\" href=\"https://github.com/filecoin-station/core/issues/3\">filecoin-station/core#3</a></li>\n</ul>\n</li>\n<li class=\"task-list-item\"><input type=\"checkbox\" id=\"\" disabled=\"\" class=\"task-list-item-checkbox\" checked=\"\"> Configuration\n<ul dir=\"auto\">\n<li><a class=\"issue-link js-issue-link\" data-error-text=\"Failed to load title\" data-id=\"1597339809\" data-permission-text=\"Title is private\" data-url=\"https://github.com/filecoin-station/core/issues/4\" data-hovercard-type=\"issue\" data-hovercard-url=\"/filecoin-station/core/issues/4/hovercard\" href=\"https://github.com/filecoin-station/core/issues/4\">filecoin-station/core#4</a></li>\n</ul>\n</li>\n<li class=\"task-list-item\"><input type=\"checkbox\" id=\"\" disabled=\"\" class=\"task-list-item-checkbox\" checked=\"\"> Storage\n<ul dir=\"auto\">\n<li><a class=\"issue-link js-issue-link\" data-error-text=\"Failed to load title\" data-id=\"1597342272\" data-permission-text=\"Title is private\" data-url=\"https://github.com/filecoin-station/core/issues/5\" data-hovercard-type=\"issue\" data-hovercard-url=\"/filecoin-station/core/issues/5/hovercard\" href=\"https://github.com/filecoin-station/core/issues/5\">filecoin-station/core#5</a></li>\n<li><a class=\"issue-link js-issue-link\" data-error-text=\"Failed to load title\" data-id=\"1597344773\" data-permission-text=\"Title is private\" data-url=\"https://github.com/filecoin-station/core/issues/6\" data-hovercard-type=\"issue\" data-hovercard-url=\"/filecoin-station/core/issues/6/hovercard\" href=\"https://github.com/filecoin-station/core/issues/6\">filecoin-station/core#6</a></li>\n<li><a class=\"issue-link js-issue-link\" data-error-text=\"Failed to load title\" data-id=\"1597346671\" data-permission-text=\"Title is private\" data-url=\"https://github.com/filecoin-station/core/issues/7\" data-hovercard-type=\"issue\" data-hovercard-url=\"/filecoin-station/core/issues/7/hovercard\" href=\"https://github.com/filecoin-station/core/issues/7\">filecoin-station/core#7</a></li>\n<li><a class=\"issue-link js-issue-link\" data-error-text=\"Failed to load title\" data-id=\"1597347341\" data-permission-text=\"Title is private\" data-url=\"https://github.com/filecoin-station/core/issues/8\" data-hovercard-type=\"issue\" data-hovercard-url=\"/filecoin-station/core/issues/8/hovercard\" href=\"https://github.com/filecoin-station/core/issues/8\">filecoin-station/core#8</a></li>\n</ul>\n</li>\n<li class=\"task-list-item\"><input type=\"checkbox\" id=\"\" disabled=\"\" class=\"task-list-item-checkbox\" checked=\"\"> Process management\n<ul dir=\"auto\">\n<li><a class=\"issue-link js-issue-link\" data-error-text=\"Failed to load title\" data-id=\"1603641447\" data-permission-text=\"Title is private\" data-url=\"https://github.com/filecoin-station/core/issues/9\" data-hovercard-type=\"issue\" data-hovercard-url=\"/filecoin-station/core/issues/9/hovercard\" href=\"https://github.com/filecoin-station/core/issues/9\">filecoin-station/core#9</a></li>\n<li><a class=\"issue-link js-issue-link\" data-error-text=\"Failed to load title\" data-id=\"1603642035\" data-permission-text=\"Title is private\" data-url=\"https://github.com/filecoin-station/core/issues/10\" data-hovercard-type=\"issue\" data-hovercard-url=\"/filecoin-station/core/issues/10/hovercard\" href=\"https://github.com/filecoin-station/core/issues/10\">filecoin-station/core#10</a></li>\n<li><a class=\"issue-link js-issue-link\" data-error-text=\"Failed to load title\" data-id=\"1603642771\" data-permission-text=\"Title is private\" data-url=\"https://github.com/filecoin-station/core/issues/11\" data-hovercard-type=\"issue\" data-hovercard-url=\"/filecoin-station/core/issues/11/hovercard\" href=\"https://github.com/filecoin-station/core/issues/11\">filecoin-station/core#11</a></li>\n<li><a class=\"issue-link js-issue-link\" data-error-text=\"Failed to load title\" data-id=\"1603643495\" data-permission-text=\"Title is private\" data-url=\"https://github.com/filecoin-station/core/issues/12\" data-hovercard-type=\"issue\" data-hovercard-url=\"/filecoin-station/core/issues/12/hovercard\" href=\"https://github.com/filecoin-station/core/issues/12\">filecoin-station/core#12</a></li>\n<li><a class=\"issue-link js-issue-link\" data-error-text=\"Failed to load title\" data-id=\"1603646564\" data-permission-text=\"Title is private\" data-url=\"https://github.com/filecoin-station/core/issues/13\" data-hovercard-type=\"issue\" data-hovercard-url=\"/filecoin-station/core/issues/13/hovercard\" href=\"https://github.com/filecoin-station/core/issues/13\">filecoin-station/core#13</a></li>\n<li><a class=\"issue-link js-issue-link\" data-error-text=\"Failed to load title\" data-id=\"1603647290\" data-permission-text=\"Title is private\" data-url=\"https://github.com/filecoin-station/core/issues/14\" data-hovercard-type=\"issue\" data-hovercard-url=\"/filecoin-station/core/issues/14/hovercard\" href=\"https://github.com/filecoin-station/core/issues/14\">filecoin-station/core#14</a></li>\n</ul>\n</li>\n<li class=\"task-list-item\"><input type=\"checkbox\" id=\"\" disabled=\"\" class=\"task-list-item-checkbox\" checked=\"\"> Metrics\n<ul dir=\"auto\">\n<li><a class=\"issue-link js-issue-link\" data-error-text=\"Failed to load title\" data-id=\"1603648233\" data-permission-text=\"Title is private\" data-url=\"https://github.com/filecoin-station/core/issues/15\" data-hovercard-type=\"issue\" data-hovercard-url=\"/filecoin-station/core/issues/15/hovercard\" href=\"https://github.com/filecoin-station/core/issues/15\">filecoin-station/core#15</a></li>\n<li><a class=\"issue-link js-issue-link\" data-error-text=\"Failed to load title\" data-id=\"1603649235\" data-permission-text=\"Title is private\" data-url=\"https://github.com/filecoin-station/core/issues/16\" data-hovercard-type=\"issue\" data-hovercard-url=\"/filecoin-station/core/issues/16/hovercard\" href=\"https://github.com/filecoin-station/core/issues/16\">filecoin-station/core#16</a></li>\n</ul>\n</li>\n<li class=\"task-list-item\"><input type=\"checkbox\" id=\"\" disabled=\"\" class=\"task-list-item-checkbox\" checked=\"\"> Documentation\n<ul dir=\"auto\">\n<li><a class=\"issue-link js-issue-link\" data-error-text=\"Failed to load title\" data-id=\"1603651644\" data-permission-text=\"Title is private\" data-url=\"https://github.com/filecoin-station/core/issues/17\" data-hovercard-type=\"issue\" data-hovercard-url=\"/filecoin-station/core/issues/17/hovercard\" href=\"https://github.com/filecoin-station/core/issues/17\">filecoin-station/core#17</a></li>\n</ul>\n</li>\n</ul>\n<h3 dir=\"auto\">Usage</h3>\n<div class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Installation\n$ npm install -g @filecoin-station/core\n$ station\n...\n\n# Configuration\n$ export STATION_ROOT=~/.station/ # (default)\n$ export STATION_FIL_WALLET_ADDRESS=f1...\n\n# Get latest metrics\n$ tail -n1 $STATION_ROOT/logs/metrics.log\n2023-02-16T22:59:47.385+0100 {&quot;totalJobsCompleted&quot;:123}\n\n# List module logs\n$ tail -f $STATION_ROOT/logs/modules/saturn-l2-node{,.err}.log\n==&gt; $STATION_ROOT/logs/modules/saturn-l2-node.log &lt;==\n2023-02-16T22:59:47.385+0100 INFO: Saturn Node is online and connected to 9 peers\n2023-02-16T22:59:47.385+0100 ERROR: Saturn Node is not able to connect to the network\n\n==&gt; $STATION_ROOT/logs/modules/saturn-l2-node.err.log &lt;==\n2023-02-16T22:59:47.385+0100 Dang!\n...\n\"><pre class=\"notranslate\"><span class=\"pl-c\"><span class=\"pl-c\">#</span> Installation</span>\n$ npm install -g @filecoin-station/core\n$ station\n...\n\n<span class=\"pl-c\"><span class=\"pl-c\">#</span> Configuration</span>\n$ <span class=\"pl-k\">export</span> STATION_ROOT=<span class=\"pl-k\">~</span>/.station/ <span class=\"pl-c\"><span class=\"pl-c\">#</span> (default)</span>\n$ <span class=\"pl-k\">export</span> STATION_FIL_WALLET_ADDRESS=f1...\n\n<span class=\"pl-c\"><span class=\"pl-c\">#</span> Get latest metrics</span>\n$ tail -n1 <span class=\"pl-smi\">$STATION_ROOT</span>/logs/metrics.log\n2023-02-16T22:59:47.385+0100 {<span class=\"pl-s\"><span class=\"pl-pds\">\"</span>totalJobsCompleted<span class=\"pl-pds\">\"</span></span>:123}\n\n<span class=\"pl-c\"><span class=\"pl-c\">#</span> List module logs</span>\n$ tail -f <span class=\"pl-smi\">$STATION_ROOT</span>/logs/modules/saturn-l2-node{,.err}.log\n==<span class=\"pl-k\">&gt;</span> <span class=\"pl-smi\">$STATION_ROOT</span>/logs/modules/saturn-l2-node.log <span class=\"pl-k\">&lt;</span>==\n2023-02-16T22:59:47.385+0100 INFO: Saturn Node is online and connected to 9 peers\n2023-02-16T22:59:47.385+0100 ERROR: Saturn Node is not able to connect to the network\n\n==<span class=\"pl-k\">&gt;</span> <span class=\"pl-smi\">$STATION_ROOT</span>/logs/modules/saturn-l2-node.err.log <span class=\"pl-k\">&lt;</span>==\n2023-02-16T22:59:47.385+0100 Dang<span class=\"pl-k\">!</span>\n...\n</pre></div>\n<p dir=\"auto\">Milestone: <a href=\"https://github.com/filecoin-station/core/milestone/1\">https://github.com/filecoin-station/core/milestone/1</a></p>",
"body": "ETA: 2023-04-01\r\n\r\nDescription: Develop a functional but rudimentary `Station Core` (ex `Station headless`) binary for early adopters.\r\n\r\nChildren:\r\n- [x] Bundled Modules\r\n - https://github.com/filecoin-station/core/issues/1\r\n- [x] CLI\r\n - https://github.com/filecoin-station/core/issues/2\r\n - https://github.com/filecoin-station/core/issues/3\r\n- [x] Configuration\r\n - https://github.com/filecoin-station/core/issues/4\r\n- [x] Storage\r\n - https://github.com/filecoin-station/core/issues/5\r\n - https://github.com/filecoin-station/core/issues/6\r\n - https://github.com/filecoin-station/core/issues/7\r\n - https://github.com/filecoin-station/core/issues/8\r\n- [x] Process management\r\n - https://github.com/filecoin-station/core/issues/9\r\n - https://github.com/filecoin-station/core/issues/10\r\n - https://github.com/filecoin-station/core/issues/11\r\n - https://github.com/filecoin-station/core/issues/12\r\n - https://github.com/filecoin-station/core/issues/13\r\n - https://github.com/filecoin-station/core/issues/14\r\n- [x] Metrics\r\n - https://github.com/filecoin-station/core/issues/15\r\n - https://github.com/filecoin-station/core/issues/16\r\n- [x] Documentation\r\n - https://github.com/filecoin-station/core/issues/17\r\n \r\n### Usage\r\n\r\n```bash\r\n# Installation\r\n$ npm install -g @filecoin-station/core\r\n$ station\r\n...\r\n\r\n# Configuration\r\n$ export STATION_ROOT=~/.station/ # (default)\r\n$ export STATION_FIL_WALLET_ADDRESS=f1...\r\n\r\n# Get latest metrics\r\n$ tail -n1 $STATION_ROOT/logs/metrics.log\r\n2023-02-16T22:59:47.385+0100 {\"totalJobsCompleted\":123}\r\n\r\n# List module logs\r\n$ tail -f $STATION_ROOT/logs/modules/saturn-l2-node{,.err}.log\r\n==> $STATION_ROOT/logs/modules/saturn-l2-node.log <==\r\n2023-02-16T22:59:47.385+0100 INFO: Saturn Node is online and connected to 9 peers\r\n2023-02-16T22:59:47.385+0100 ERROR: Saturn Node is not able to connect to the network\r\n\r\n==> $STATION_ROOT/logs/modules/saturn-l2-node.err.log <==\r\n2023-02-16T22:59:47.385+0100 Dang!\r\n...\r\n\r\n```\r\n\r\nMilestone: https://github.com/filecoin-station/core/milestone/1",
"labels": [
"station core"
],
"description": ""
}
SgtPooki marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions tests/unit/getValidUrlFromInput.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ describe('getValidUrlFromInput', function() {
})

it('should throw an error on an invalid urlString', function() {
// expect(getValidUrlFromInput('invalid url string')).toEqual(new URL('https://www.google.com'));
expect(() => getValidUrlFromInput('invalid url string')).toThrowError('Unsupported URL string. URLs should be formatted like a github issue');
// console.log(`getValidUrlFromInput('invalid url string'): `, getValidUrlFromInput('invalid url string'));
expect(() => getValidUrlFromInput('#')).toThrowError('Unsupported URL string. URLs should be formatted like a github issue');
expect(() => getValidUrlFromInput('###')).toThrowError('Unsupported URL string. URLs should be formatted like a github issue');
})
})
6 changes: 6 additions & 0 deletions tests/unit/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ describe('parser', function() {
const children = getChildren(issueJson);
expect(children).toHaveLength(8)
})
it('bug372', async function() {
// test for bug https://github.com/pln-planning-tools/Starmap/issues/372
const issueJson = await import('../fixtures/getIssueResult/filecoin-station-roadmap-12.json');
const children = getChildren(issueJson);
expect(children).toHaveLength(17);
})
})

describe('getDescription', function() {
Expand Down