-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
1 parent
8d74328
commit cb62f6d
Showing
4 changed files
with
61 additions
and
6 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,40 @@ | ||
import {Options as NormalizeUrlOptions} from 'normalize-url'; | ||
|
||
declare namespace getUrls { | ||
interface Options extends NormalizeUrlOptions { | ||
/** | ||
Extract URLs that appear as query parameters in the found URLs. | ||
@default false | ||
*/ | ||
readonly extractFromQueryString?: boolean; | ||
|
||
/** | ||
Exclude URLs that match URLs in the given array. | ||
@default [] | ||
*/ | ||
readonly exclude?: string[]; | ||
} | ||
} | ||
|
||
/** | ||
Get all URLs in a string. | ||
The URLs will be [normalized](https://github.com/sindresorhus/normalize-url). | ||
@returns A `Set` of URLs. | ||
@example | ||
``` | ||
import getUrls = require('get-urls'); | ||
const text = 'Lorem ipsum dolor sit amet, //sindresorhus.com consectetuer adipiscing http://yeoman.io elit.'; | ||
getUrls(text); | ||
//=> Set {'http://sindresorhus.com', 'http://yeoman.io'} | ||
``` | ||
*/ | ||
declare function getUrls(text: string, options?: getUrls.Options): Set<string>; | ||
|
||
export = getUrls; |
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,10 @@ | ||
import {expectType} from 'tsd'; | ||
import getUrls = require('.'); | ||
|
||
const text = | ||
'Lorem ipsum dolor sit amet, //sindresorhus.com consectetuer adipiscing http://yeoman.io elit.'; | ||
|
||
expectType<Set<string>>(getUrls(text)); | ||
expectType<Set<string>>(getUrls(text, {extractFromQueryString: true})); | ||
expectType<Set<string>>(getUrls(text, {exclude: ['foo']})); | ||
expectType<Set<string>>(getUrls(text, {defaultProtocol: 'ftp'})); |
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
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