Skip to content

Commit

Permalink
refactor: drop Node.js 8 (#191)
Browse files Browse the repository at this point in the history
* refactor: utilize url#from
* ci(appveyor): drop Node.js 8
* chore: require Node.js 10.13.0 or higher
  • Loading branch information
SukkaW committed Apr 26, 2020
1 parent 20a3c1b commit b990b8f
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Expand Up @@ -5,10 +5,10 @@ init:
# Test against these versions of Node.js.
environment:
matrix:
- nodejs_version: "8"
- nodejs_version: "10"
- nodejs_version: "12"
- nodejs_version: "13"
- nodejs_version: "14"

matrix:
fast_finish: true
Expand Down
6 changes: 2 additions & 4 deletions lib/decode_url.js
@@ -1,7 +1,6 @@
'use strict';

const { parse, URL } = require('url');
const { toUnicode } = require('punycode.js');
const { parse, format } = require('url');

const safeDecodeURI = str => {
try {
Expand All @@ -18,8 +17,7 @@ const decodeURL = str => {
// Exit if input is a data url
if (parsed.origin === 'null') return str;

// TODO: refactor to `url.format()` once Node 8 is dropped
const url = parsed.toString().replace(parsed.hostname, toUnicode(parsed.hostname));
const url = format(parsed, { unicode: true });
return safeDecodeURI(url);
}

Expand Down
6 changes: 2 additions & 4 deletions lib/encode_url.js
@@ -1,7 +1,6 @@
'use strict';

const { toUnicode } = require('punycode.js');
const { parse, URL } = require('url');
const { parse, format } = require('url');

const safeDecodeURI = str => {
try {
Expand All @@ -20,8 +19,7 @@ const encodeURL = str => {

parsed.search = encodeURI(safeDecodeURI(parsed.search));
// preserve IDN
// TODO: refactor to url.format() once Node 8 EOL
return parsed.toString().replace(parsed.hostname, toUnicode(parsed.hostname));
return format(parsed, { unicode: true });
}

return encodeURI(safeDecodeURI(str));
Expand Down
2 changes: 1 addition & 1 deletion lib/full_url_for.js
@@ -1,6 +1,6 @@
'use strict';

const { parse, URL } = require('url');
const { parse } = require('url');
const encodeURL = require('./encode_url');
const prettyUrls = require('./pretty_urls');

Expand Down
2 changes: 1 addition & 1 deletion lib/is_external_link.js
@@ -1,6 +1,6 @@
'use strict';

const { parse, URL } = require('url');
const { parse } = require('url');

const Cache = require('./cache');
const cache = new Cache();
Expand Down
2 changes: 1 addition & 1 deletion lib/url_for.js
@@ -1,6 +1,6 @@
'use strict';

const { parse, URL } = require('url');
const { parse } = require('url');
const encodeURL = require('./encode_url');
const relative_url = require('./relative_url');
const prettyUrls = require('./pretty_urls');
Expand Down
3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -50,11 +50,10 @@
"highlight.js": "^10.0.0",
"htmlparser2": "^4.0.0",
"prismjs": "^1.17.1",
"punycode.js": "^2.1.0",
"strip-indent": "^3.0.0",
"striptags": "^3.1.1"
},
"engines": {
"node": ">=8.6.0"
"node": ">=10.13.0"
}
}

0 comments on commit b990b8f

Please sign in to comment.