-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6fac1f4
Showing
14 changed files
with
642 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
files: | ||
- package.json | ||
plugins: | ||
prerelease: | ||
Linting config files: | ||
plugin: bumped-finepack | ||
postrelease: | ||
Generating CHANGELOG file: | ||
plugin: bumped-changelog | ||
Committing new version: | ||
plugin: bumped-terminal | ||
command: 'git add CHANGELOG.md package.json && git commit -m "Release $newVersion"' | ||
Detecting problems before publish: | ||
plugin: bumped-terminal | ||
command: 'git-dirty && npm test' | ||
Publishing tag to GitHub: | ||
plugin: bumped-terminal | ||
command: 'git tag $newVersion && git push && git push --tags' | ||
Publishing to NPM: | ||
plugin: bumped-terminal | ||
command: npm publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# http://editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
max_line_length = 100 | ||
indent_brace_style = 1TBS | ||
spaces_around_operators = true | ||
quote_type = auto | ||
|
||
[package.json] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
############################ | ||
# npm | ||
############################ | ||
node_modules | ||
npm-debug.log | ||
.node_history | ||
yarn.lock | ||
package-lock.json | ||
|
||
############################ | ||
# tmp, editor & OS files | ||
############################ | ||
.tmp | ||
*.swo | ||
*.swp | ||
*.swn | ||
*.swm | ||
.DS_Store | ||
*# | ||
*~ | ||
.idea | ||
*sublime* | ||
nbproject | ||
|
||
############################ | ||
# Tests | ||
############################ | ||
testApp | ||
coverage | ||
.nyc_output | ||
|
||
############################ | ||
# Other | ||
############################ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
unsafe-perm=true | ||
save-prefix=~ | ||
shrinkwrap=false | ||
save=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
language: node_js | ||
node_js: | ||
- "node" | ||
- "lts/*" | ||
after_success: npm run coveralls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright © 2018 Kiko Beats <josefrancisco.verdu@gmail.com> (kikobeats.com) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# html-links | ||
|
||
![Last version](https://img.shields.io/github/tag/Kikobeats/html-links.svg?style=flat-square) | ||
[![Build Status](https://img.shields.io/travis/Kikobeats/html-links/master.svg?style=flat-square)](https://travis-ci.org/Kikobeats/html-links) | ||
[![Coverage Status](https://img.shields.io/coveralls/Kikobeats/html-links.svg?style=flat-square)](https://coveralls.io/github/Kikobeats/html-links) | ||
[![Dependency status](https://img.shields.io/david/Kikobeats/html-links.svg?style=flat-square)](https://david-dm.org/Kikobeats/html-links) | ||
[![Dev Dependencies Status](https://img.shields.io/david/dev/Kikobeats/html-links.svg?style=flat-square)](https://david-dm.org/Kikobeats/html-links#info=devDependencies) | ||
[![NPM Status](https://img.shields.io/npm/dm/html-links.svg?style=flat-square)](https://www.npmjs.org/package/html-links) | ||
[![Donate](https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square)](https://paypal.me/Kikobeats) | ||
|
||
> Get all links from a HTML markup. | ||
## Install | ||
|
||
```bash | ||
$ npm install html-links --save | ||
``` | ||
|
||
## Usage | ||
|
||
```js | ||
const got = require('got') | ||
const getLinks = require('html-links') | ||
|
||
;(async() => { | ||
const url = process.argv[2] | ||
if (!url) throw new TypeError('Need to provide an url as first argument.') | ||
const {body: html} = await got(url) | ||
const links = getLinks({html, url}) | ||
|
||
console.log(links) | ||
|
||
// => [ | ||
// 'https://microlink.io/component---src-layouts-index-js-86b5f94dfa48cb04ae41.js', | ||
// 'https://microlink.io/component---src-pages-index-js-a302027ab59365471b7d.js', | ||
// 'https://microlink.io/path---index-709b6cf5b986a710cc3a.js', | ||
// 'https://microlink.io/app-8b4269e1fadd08e6ea1e.js', | ||
// 'https://microlink.io/commons-8b286eac293678e1c98c.js', | ||
// 'https://microlink.io', | ||
// ... | ||
// ] | ||
})() | ||
``` | ||
|
||
See [examples](/examples). | ||
|
||
## API | ||
|
||
### links([options]) | ||
|
||
#### options | ||
|
||
##### html | ||
|
||
Type: `string`<br> | ||
Default: `''` | ||
|
||
The HTML markup. | ||
|
||
##### url | ||
|
||
Type: `string`<br> | ||
Default: `''` | ||
|
||
The URL associated with the HTML markup. | ||
|
||
It is used for resolve relative links that can be present in the HTML markup. | ||
|
||
##### backlist | ||
|
||
Type: `array`<br> | ||
Default: `[]` | ||
|
||
A list of links to be excluded from the final output. It supports regex patterns. | ||
|
||
## License | ||
|
||
**html-links** © [Kiko Beats](https://kikobeats.com), released under the [MIT](https://github.com/Kikobeats/html-links/blob/master/LICENSE.md) License.<br> | ||
Authored and maintained by Kiko Beats with help from [contributors](https://github.com/Kikobeats/html-links/contributors). | ||
|
||
> [kikobeats.com](https://kikobeats.com) · GitHub [@Kiko Beats](https://github.com/Kikobeats) · Twitter [@Kikobeats](https://twitter.com/Kikobeats) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
exports['get links from a semantic markup 1'] = [ | ||
{ | ||
"normalized": "https://google.com", | ||
"origin": "https://google.com" | ||
}, | ||
{ | ||
"normalized": "https://facebook.com", | ||
"origin": "https://facebook.com" | ||
} | ||
] | ||
|
||
exports['remove duplicate links 1'] = [ | ||
{ | ||
"normalized": "https://google.com", | ||
"origin": "https://google.com" | ||
}, | ||
{ | ||
"normalized": "https://facebook.com", | ||
"origin": "https://facebook.com" | ||
} | ||
] | ||
|
||
exports['final slash doesnt matter 1'] = [ | ||
{ | ||
"normalized": "https://google.com", | ||
"origin": "https://google.com/" | ||
}, | ||
{ | ||
"normalized": "https://facebook.com", | ||
"origin": "https://facebook.com" | ||
} | ||
] | ||
|
||
exports['query string parameters position are not relevant 1'] = [ | ||
{ | ||
"normalized": "https://google.com/?foo=bar&hello=world", | ||
"origin": "https://google.com?hello=world&foo=bar" | ||
}, | ||
{ | ||
"normalized": "https://facebook.com", | ||
"origin": "https://facebook.com" | ||
} | ||
] | ||
|
||
exports['tag `link` support 1'] = [ | ||
{ | ||
"normalized": "https://microlink.io/default.css", | ||
"origin": "default.css" | ||
} | ||
] | ||
|
||
exports['resolve relative links 1'] = [ | ||
{ | ||
"normalized": "https://microlink.io/login", | ||
"origin": "/login" | ||
} | ||
] | ||
|
||
exports['string support 1'] = [ | ||
{ | ||
"normalized": "https://facebook.com", | ||
"origin": "https://facebook.com" | ||
} | ||
] | ||
|
||
exports['regex support 1'] = [ | ||
{ | ||
"normalized": "https://facebook.com", | ||
"origin": "https://facebook.com" | ||
} | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use strict' | ||
|
||
const getLinks = require('.') | ||
const got = require('got') | ||
;(async () => { | ||
const url = process.argv[2] | ||
if (!url) throw new TypeError('Need to provide an url as first argument.') | ||
const { body: html } = await got(url) | ||
const links = getLinks({ html, url }) | ||
|
||
links.forEach(({ normalized, origin }, index) => console.log(normalized)) | ||
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{ | ||
"name": "html-links", | ||
"description": "Get all links from a HTML markup", | ||
"homepage": "https://documentup.com/Kikobeats/html-links", | ||
"version": "0.0.0", | ||
"main": "src/index.js", | ||
"author": { | ||
"email": "josefrancisco.verdu@gmail.com", | ||
"name": "Kiko Beats", | ||
"url": "https://kikobeats.com" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Kikobeats/html-links.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/Kikobeats/html-links/issues" | ||
}, | ||
"keywords": [ | ||
"href", | ||
"hrefs", | ||
"html", | ||
"link", | ||
"links", | ||
"src", | ||
"url", | ||
"urls" | ||
], | ||
"dependencies": { | ||
"@metascraper/helpers": "~3.4.3", | ||
"cheerio": "~1.0.0-rc.2", | ||
"lodash": "~4.17.4", | ||
"url-pattern": "~1.0.3" | ||
}, | ||
"devDependencies": { | ||
"chalk": "~2.3.0", | ||
"coveralls": "latest", | ||
"finepack": "latest", | ||
"git-dirty": "latest", | ||
"got": "~8.0.2", | ||
"husky": "latest", | ||
"lint-staged": "latest", | ||
"mocha": "latest", | ||
"nyc": "latest", | ||
"prettier-standard": "latest", | ||
"should": "latest", | ||
"snap-shot": "latest", | ||
"standard": "latest", | ||
"standard-markdown": "latest" | ||
}, | ||
"engines": { | ||
"node": ">= 6" | ||
}, | ||
"files": [ | ||
"src" | ||
], | ||
"scripts": { | ||
"clean": "rm -rf node_modules", | ||
"coveralls": "nyc report --reporter=text-lcov | coveralls", | ||
"lint": "standard-markdown && standard", | ||
"precommit": "lint-staged", | ||
"pretest": "npm run lint", | ||
"pretty": "prettier-standard index.js {core,test,bin}/**/*.js --single-quote", | ||
"test": "nyc mocha" | ||
}, | ||
"license": "MIT", | ||
"lint-staged": { | ||
"package.json": [ | ||
"finepack", | ||
"git add" | ||
], | ||
"*.js": [ | ||
"prettier-standard", | ||
"git add" | ||
] | ||
}, | ||
"standard": { | ||
"env": [ | ||
"mocha" | ||
] | ||
} | ||
} |
Oops, something went wrong.