Skip to content

Commit 7fcaa77

Browse files
authored
Merge pull request #8 from g0rdan/dont-show-private-repos
fix: check for http response status
2 parents bc5871c + 384bbdd commit 7fcaa77

File tree

5 files changed

+19
-6
lines changed

5 files changed

+19
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## [0.1.3]
4+
5+
- Fix issue when we try to show URL to a package that does not exist on pub.dev.
6+
37
## [0.1.2]
48

59
- Attempt to fix "colon" [issue](https://github.com/g0rdan/publink/issues/5)

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ This extension allows you to see a hover with package's info from [pub.dev](http
88

99
## Release Notes
1010

11+
### 0.1.3
12+
13+
- Fix issue when we try to show URL to a package that does not exist on pub.dev.
14+
1115
### 0.1.2
1216

1317
- Attempt to fix "colon" [issue](https://github.com/g0rdan/publink/issues/5)

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"publisher": "gordin",
44
"displayName": "PubLink",
55
"description": "PubLink allows you quickly open a flutter/dart package on pub.dev",
6-
"version": "0.1.2",
6+
"version": "0.1.3",
77
"license": "MIT",
88
"icon": "assets/icons/main_icon.png",
99
"repository": {

src/module.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,20 @@ export class PubLinkModule {
5555
var data = new PackageData();
5656
try {
5757
// Fetch the HTML content from the web
58-
const response = await axios.get(url);
58+
const response = await axios.get(url).catch((error) => {
59+
// If a request is outside of the 200 range, we want to return null
60+
if (error.response) {
61+
return null;
62+
}
63+
});
5964
// We want to make sure the URL is valid. There could be situations where
6065
// we have a git or local dependency, we don't want to mislead users with
6166
// these URLs.
62-
if (response.status !== 200) {
67+
if (response === null) {
6368
return null;
6469
}
6570

66-
const html = response.data;
71+
const html = response!.data;
6772

6873
// Parse the HTML content using jsdom
6974
const dom = new JSDOM(html);

0 commit comments

Comments
 (0)