Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
23 changes: 23 additions & 0 deletions lib/isUrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Copyright © 2018 Andrew Powell

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of this Source Code Form.
*/
const { isWebUri } = require('valid-url');

const isUrl = (url) => {
let toValidate = url;

if (url.startsWith('//')) {
toValidate = `http:${url}`;
}

return Boolean(isWebUri(toValidate));
};

module.exports = { isUrl };
2 changes: 1 addition & 1 deletion lib/nodes/Word.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
included in all copies or substantial portions of this Source Code Form.
*/
const colors = require('color-name');
const isUrl = require('is-url-superb');

const { isUrl } = require('../isUrl');
const { registerWalker } = require('../walker');

const Node = require('./Node');
Expand Down
30 changes: 7 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@
],
"dependencies": {
"color-name": "^1.1.4",
"is-url-superb": "^3.0.0",
"postcss": "^7.0.5",
"url-regex": "^5.0.0"
"valid-url": "^1.0.9"
},
"devDependencies": {
"ava": "^3.5.1",
Expand Down