Skip to content

Commit 2c7d823

Browse files
authored
Fix: uri encode input (fix #1) (#2)
* Chore: update deps * Chore: update babel and eslint * Chore: mv from yarn to npm * Test: update tests and mv from ava to jest * Fix: uriEncode input * CI: update coveralls to codecov * CI: drop support for node 4,6,8 and add support for 10,12 * Docs: update badge
1 parent 8c0728b commit 2c7d823

File tree

11 files changed

+12252
-4093
lines changed

11 files changed

+12252
-4093
lines changed

.appveyor.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
environment:
22
matrix:
3-
- nodejs_version: "4"
4-
- nodejs_version: "6"
5-
- nodejs_version: "8"
3+
- nodejs_version: "10"
4+
- nodejs_version: "12"
65

76
install:
87
- ps: Install-Product node $env:nodejs_version

.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"presets": [
3-
"env"
3+
"@babel/env"
44
]
55
}

.eslintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@
55
],
66
"rules": {
77
"arrow-parens": 0
8+
},
9+
"env": {
10+
"jest": true
811
}
912
}

.travis.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ language: node_js
22
sudo: true
33
dist: trusty
44
node_js:
5-
- "4"
6-
- "6"
7-
- "8"
5+
- "10"
6+
- "12"
87
install:
9-
- yarn
10-
script: npm test
8+
- npm i
9+
- npm i -g codecov
10+
script:
11+
- npm test
1112
notifications:
1213
email:
1314
on_failure: change
14-
on_success: change
1515
after_success:
16-
- npm run coveralls
16+
- codecov

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
[![Build Status](https://travis-ci.org/aichbauer/node-is-git-remote.svg?branch=master)](https://travis-ci.org/aichbauer/node-is-git-remote)
66
[![Build status](https://ci.appveyor.com/api/projects/status/eatqdfs3a7uhniti?svg=true)](https://ci.appveyor.com/project/aichbauer/node-is-git-remote)
7-
[![Coverage Status](https://coveralls.io/repos/github/aichbauer/node-is-git-remote/badge.svg?branch=master)](https://coveralls.io/github/aichbauer/node-is-git-remote?branch=master)
7+
[![codecov](https://codecov.io/gh/aichbauer/node-is-git-remote/branch/master/graph/badge.svg)](https://codecov.io/gh/aichbauer/node-is-git-remote)
88

99
## Installation
1010

lib/index.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,32 @@ const isGitRemte = (URL, host) => {
66
const thisHost = host || 'github.com';
77

88
if (inputIs.url(thisURL) && !inputIs.valid(thisURL, /https:\/\//)) {
9-
thisURL = `https://${thisURL}`;
9+
const splittedURL = thisURL.split('/');
10+
const url = splittedURL.map((item) => encodeURIComponent(item)).join('/');
11+
12+
thisURL = `https://${url}`;
1013
} else if (!inputIs.url(thisURL) && inputIs.valid(thisURL, /.\/./)) {
11-
thisURL = `https://www.${thisHost}/${thisURL}`;
14+
const splittedURL = thisURL.split('/');
15+
const url = splittedURL.map((item) => encodeURIComponent(item)).join('/');
16+
const splittedHost = thisHost.split('.');
17+
const newHost = splittedHost.map((item) => encodeURIComponent(item)).join('.');
18+
19+
thisURL = `https://${newHost}/${url}`;
20+
} else if (inputIs.url(thisURL) && inputIs.valid(thisURL, /http:\/\//)) {
21+
const splittedURL = thisURL.split('http://')[1].split('/');
22+
const url = splittedURL.map((item) => encodeURIComponent(item)).join('/');
23+
24+
thisURL = `http://${url}`;
25+
} else if (inputIs.url(thisURL) && inputIs.valid(thisURL, /https:\/\//)) {
26+
const splittedURL = thisURL.split('https://')[1].split('/');
27+
const url = splittedURL.map((item) => encodeURIComponent(item)).join('/');
28+
29+
thisURL = `https://${url}`;
30+
} else {
31+
const splittedURL = thisURL.split('/');
32+
const url = splittedURL.map((item) => encodeURIComponent(item)).join('/');
33+
34+
thisURL = url;
1235
}
1336

1437
try {

0 commit comments

Comments
 (0)