├── .npmignore ├── .gitignore ├── coverage ├── lcov-report │ ├── sort-arrow-sprite.png │ ├── prettify.css │ ├── doi-regex │ │ ├── index.html │ │ ├── spec │ │ │ ├── index.html │ │ │ └── test.js.html │ │ ├── index.js.html │ │ └── test.js.html │ ├── index.html │ ├── sorter.js │ ├── base.css │ └── prettify.js ├── lcov.info └── coverage.json ├── .travis.yml ├── CITATION.cff ├── license ├── package.json ├── cli-index.js ├── index.js ├── readme.md └── spec └── test.js /.npmignore: -------------------------------------------------------------------------------- 1 | coverage 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /coverage/lcov-report/sort-arrow-sprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/regexhq/doi-regex/HEAD/coverage/lcov-report/sort-arrow-sprite.png -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '0.10' 4 | 5 | addons: 6 | code_climate: 7 | repo_token: a422a1696c17a5184d90637b08facc0496c55d7f3043a8d7afa2341f34633b86 8 | 9 | before_install: 10 | - "npm install -g codeclimate-test-reporter" 11 | - "npm install -g istanbul" 12 | 13 | after_script: 14 | - codeclimate < coverage/lcov.info 15 | -------------------------------------------------------------------------------- /coverage/lcov-report/prettify.css: -------------------------------------------------------------------------------- 1 | .pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} 2 | -------------------------------------------------------------------------------- /CITATION.cff: -------------------------------------------------------------------------------- 1 | # This CITATION.cff file was generated with cffinit. 2 | # Visit https://bit.ly/cffinit to generate yours today! 3 | 4 | cff-version: 1.2.0 5 | title: doi-regex 6 | message: Regular expression for matching DOIs 7 | type: software 8 | authors: 9 | - given-names: Richard 10 | family-names: Littauer 11 | orcid: 'https://orcid.org/0000-0001-5428-7535' 12 | - given-names: Katrin 13 | family-names: Leinweber 14 | orcid: 'https://orcid.org/0000-0001-5135-5758' 15 | - family-names: 'b1f6c1c4' 16 | orcid: 'https://orcid.org/0000-0003-4080-1876' 17 | - given-names: Chris 18 | family-names: Wilkinson 19 | orcid: 'https://orcid.org/0000-0003-4921-6155' 20 | - given-names: Karl 21 | family-names: Becker 22 | orcid: 'https://orcid.org/0009-0002-2714-7988' 23 | identifiers: 24 | - type: doi 25 | value: 10.5281/zenodo.11164918 26 | description: Zenodo DOI 27 | repository-code: 'https://github.com/regexhq/doi-regex' 28 | abstract: Regular expression for matching DOIs. 29 | keywords: 30 | - doi 31 | - regex 32 | license: MIT 33 | commit: 320096e7fd6d1663719b009fcd7572496181f9fa 34 | version: 0.1.17 35 | date-released: '2024-06-14' 36 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Richard Littauer (burntfen.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "doi-regex", 3 | "version": "0.1.17", 4 | "description": "Regular expression for matching DOIs", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "istanbul cover spec/test.js | node_modules/.bin/faucet" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git@github.com:regexhq/doi-regex.git" 12 | }, 13 | "keywords": [ 14 | "doi", 15 | "beagle", 16 | "regex", 17 | "regexp", 18 | "re", 19 | "match", 20 | "test", 21 | "find", 22 | "pattern", 23 | "doi", 24 | "digital object identifier", 25 | "validate" 26 | ], 27 | "author": { 28 | "name": "Richard Littauer", 29 | "email": "richard@burntfen.com", 30 | "url": "http://www.burntfen.com" 31 | }, 32 | "contributors": [ 33 | "Richard Littauer", 34 | "Katrin Leinweber", 35 | "Chris Wilkinson", 36 | "Karl Becker", 37 | "b1f6c1c4" 38 | ], 39 | "engines": { 40 | "node": ">=0.10.0" 41 | }, 42 | "license": "MIT", 43 | "bugs": { 44 | "url": "https://github.com/regexhq/doi-regex/issues" 45 | }, 46 | "homepage": "https://github.com/regexhq/doi-regex", 47 | "devDependencies": { 48 | "faucet": "0.0.1", 49 | "istanbul": "^0.4.5", 50 | "lodash": "^4.16.5", 51 | "minimist": "^1.1.0", 52 | "standard": "^16.0.4", 53 | "tape": "^4.6.2" 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /cli-index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 'use strict' 3 | 4 | var doiRegex = require('./') 5 | var argv = require('minimist')(process.argv.slice(2), { 6 | alias: { 7 | e: 'exact', 8 | d: 'declared', 9 | m: 'match', 10 | r: 'resolvePath', 11 | g: 'groups', 12 | h: 'help' 13 | }, 14 | boolean: ['e', 'd', 'm', 'g', 'h'] 15 | }) 16 | 17 | if (argv.h) { 18 | console.error( 19 | 'Usage: ' + process.argv[1] + ' \n' + 20 | 'Options: \n' + 21 | '-e, --exact Find an exact match \n' + 22 | '-d, --declared Find a DOI with a `doi:` prefix\n' + 23 | '-r, --resolvePath Find a DOI with a `https://dx.doi.org` prefix\n' + 24 | '-m, --match Find all matches within the given string\n' + 25 | '-g, --groups Find matches with groupings for extra suffixes') 26 | process.exit(-1) 27 | } 28 | 29 | var doi = (argv.doi || argv._[0]) 30 | 31 | // TODO This is not the best way to do this. 32 | 33 | if (argv.m) { 34 | console.log(doi.match(doiRegex())) 35 | process.exit(-1) 36 | } else if (argv.g) { 37 | console.log(doiRegex.groups(doi)) 38 | process.exit(-1) 39 | } 40 | 41 | if (argv.e && argv.d) { 42 | console.log('Is this a declared DOI', 43 | doiRegex.declared({exact: true}).test(doi)) 44 | } else if (argv.e && !argv.d && !argv.r) { 45 | console.log('Is this a DOI?', doiRegex({exact: true}).test(doi)) 46 | } else if (!argv.e && argv.d) { 47 | console.log('Is the DOI declared?', doiRegex.declared().test(doi)) 48 | } else if (!argv.e && !argv.d && argv.r) { 49 | console.log('Is the DOI declared with an optional path?', doiRegex.resolvePath().test(doi)) 50 | } else if (argv.e && !argv.d && argv.r) { 51 | console.log('Is the DOI declared with an mandatory path?', doiRegex.resolvePath({protocol: true}).test(doi)) 52 | } else { 53 | console.log('Does a DOI exist?', doiRegex().test(doi)) 54 | } 55 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | /** 4 | * Parts of a DOI: 5 | * Directory Identifier: 10 6 | * Registrant code: . + [0-9]{2,} 7 | * Registrant subdivision (optional): . + [0-9]+ 8 | * Suffix: / + any character, case insensitive for ASCII chars (but capitalised 9 | * in the registry), with some characters that _should_ be escaped. 10 | * Recommended encoding: "{}^[]`|\\&\/\'<> 11 | * Mandatory encoding: %"#? (and space) 12 | * From: http://www.doi.org/doi_handbook/2_Numbering.html#2.2 13 | */ 14 | 15 | // TODO Capture final segment for fragments 16 | // (\\.[a-zA-Z]{1}[0-9]{3})? 17 | var doiRegex = '(10[.][0-9]{2,}(?:[.][0-9]+)*/(?:(?![%"#? ])\\S)+)' 18 | var doiTextPrefix = 'doi\\:' 19 | 20 | var doi = module.exports = function (opts) { 21 | opts = opts || {} 22 | return opts.exact ? new RegExp('(?:^' + doiRegex + '$)') : 23 | new RegExp('(?:' + doiRegex + ')', 'g') 24 | } 25 | 26 | doi.groups = function (str) { 27 | if (!str) { return } 28 | // Javascript fails at lookaheads for optional groups. This circumvents that 29 | // problem by just automatically removing and saving suffixes if they are in 30 | // as specific format - .a000 is the format used by PLoS, but this may need 31 | // to be filled out. 32 | var suffixes = [] 33 | var newStr = str.replace(/\.[a-zA-Z]{1}[0-9]{3}$/g, function (s) { 34 | suffixes.push(s) 35 | return '' 36 | }) 37 | var match = doi().exec(newStr) 38 | if (match) { 39 | match[0] = str 40 | match.push((suffixes.length) ? suffixes[0] : '') 41 | } 42 | return match 43 | } 44 | 45 | doi.declared = function (opts) { 46 | opts = opts || {} 47 | return opts.exact ? new RegExp('^' + doiTextPrefix + doiRegex + '$') : 48 | new RegExp(doiTextPrefix + doiRegex, 'g') 49 | } 50 | 51 | doi.resolvePath = function (opts) { 52 | opts = opts || {} 53 | return opts.protocol ? new RegExp('^http(s)?\\://(dx\\.)?doi\\.org/' + doiRegex + '$') : 54 | new RegExp('^(http(s)?\\://)?(dx\\.)?doi\\.org/' + doiRegex + '$') 55 | } 56 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # doi-regex 2 | 3 | [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fregexhq%2Fdoi-regex.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fregexhq%2Fdoi-regex?ref=badge_shield) 4 | [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.11164917.svg)](https://zenodo.org/doi/10.5281/zenodo.11164917) 5 | 6 | > Regular expression for matching DOIs 7 | 8 | Parts of a DOI: 9 | * Directory Identifier: 10 10 | * Registrant code: . + [0-9]{2,} 11 | * Registrant subdivision (optional): . + [0-9]+ 12 | * Suffix: / + any character, case insensitive for ASCII chars (but capitalised 13 | in the registry), with some characters that _should_ be escaped 14 | Recommended encoding: ```"{}^[]`|\\&\/\'<>``` 15 | Mandatory encoding: ```%"#?``` and space. 16 | 17 | From: http://www.doi.org/doi_handbook/2_Numbering.html#2.2 18 | 19 | 20 | ## Install 21 | 22 | ```sh 23 | $ npm install --save doi-regex 24 | ``` 25 | 26 | 27 | ## Usage 28 | 29 | ```js 30 | var doiRegex = require('doi-regex'); 31 | 32 | // contains a DOI 33 | doiRegex().test('unicorn 10.1000/xyz000'); 34 | //=> true 35 | 36 | // is a DOI address 37 | doiRegex({exact: true}).test('unicorn 10.1000/xyz000'); 38 | //=> false 39 | 40 | doiRegex.declared({exact: true}).test('doi:10.1000/xyz000'); 41 | //=> true 42 | 43 | doiRegex.groups().test('10.1000/xyz1000.a001'); 44 | //=> ['10.1000/xyz1000', '10.1000/xyz1000', '.a001'] 45 | 46 | 'unicorn 10.1000/xyz000 cake 10.1000/xyz001 rainbow'.match(doiRegex()); 47 | //=> ['10.1000/xyz000', '10.1000/xyz001'] 48 | ``` 49 | 50 | 51 | ## API 52 | 53 | ### doiRegex(options) 54 | 55 | Returns a regex for matching a DOI. 56 | 57 | ### doiRegex.declared(options) 58 | 59 | Returns a regex for matching a DOI that has been declared with a `doi:` string in front. 60 | 61 | ### doiRegex.groups(doi) 62 | 63 | Returns a regex match object with a final string as the first two indices, and any suffixes that are commonly used for supplemental information if they are attached to the doi. For instance, `10.1000/journal.pone.0000000.g001` would return `10.1000/journal.pone.0000000` and `.g001`. 64 | 65 | #### options.exact 66 | 67 | Type: `boolean` 68 | Default: `false` *(Matches any DOI in a string)* 69 | 70 | Only match an exact string. 71 | Useful with `RegExp#test` to check if a string is an DOI. 72 | 73 | 74 | ## CLI 75 | 76 | A CLI file has been provided. Run any of the examples provided above using your own DOI. For instance: 77 | 78 | ```sh 79 | $ node cli-index.js -e 10.000/xyz1000 80 | //=> true 81 | ``` 82 | 83 | Possible Flags: 84 | 85 | * `-e`, `--exact` Find an exact match 86 | * `-d`, `--declared` Find a DOI with a 'doi:' prefix 87 | * `-m`, `--match` Find all matches within the given string 88 | * `-g`, `--groups` Find the stripped DOI and any suffix it might have 89 | * `-h`, `--help` Display usage 90 | 91 | ## Contribute 92 | 93 | Please do! 94 | 95 | ## License 96 | 97 | MIT © [Richard Littauer](http://burntfen.com) 98 | 99 | 100 | [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fregexhq%2Fdoi-regex.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fregexhq%2Fdoi-regex?ref=badge_large) 101 | -------------------------------------------------------------------------------- /coverage/lcov.info: -------------------------------------------------------------------------------- 1 | TN: 2 | SF:/Users/richard/src/doi-regex/spec/test.js 3 | FN:65,(anonymous_1) 4 | FN:66,(anonymous_2) 5 | FN:72,(anonymous_3) 6 | FN:73,(anonymous_4) 7 | FN:79,(anonymous_5) 8 | FN:80,(anonymous_6) 9 | FN:86,(anonymous_7) 10 | FN:87,(anonymous_8) 11 | FN:93,(anonymous_9) 12 | FN:94,(anonymous_10) 13 | FN:100,(anonymous_11) 14 | FN:101,(anonymous_12) 15 | FN:107,(anonymous_13) 16 | FN:108,(anonymous_14) 17 | FN:114,(anonymous_15) 18 | FN:115,(anonymous_16) 19 | FN:118,(anonymous_17) 20 | FN:124,(anonymous_18) 21 | FN:125,(anonymous_19) 22 | FN:128,(anonymous_20) 23 | FN:131,(anonymous_21) 24 | FN:137,(anonymous_22) 25 | FN:138,(anonymous_23) 26 | FN:141,(anonymous_24) 27 | FN:147,(anonymous_25) 28 | FN:148,(anonymous_26) 29 | FN:151,(anonymous_27) 30 | FN:157,(anonymous_28) 31 | FN:158,(anonymous_29) 32 | FN:161,(anonymous_30) 33 | FNF:30 34 | FNH:30 35 | FNDA:1,(anonymous_1) 36 | FNDA:4,(anonymous_2) 37 | FNDA:1,(anonymous_3) 38 | FNDA:1,(anonymous_4) 39 | FNDA:1,(anonymous_5) 40 | FNDA:4,(anonymous_6) 41 | FNDA:1,(anonymous_7) 42 | FNDA:4,(anonymous_8) 43 | FNDA:1,(anonymous_9) 44 | FNDA:1,(anonymous_10) 45 | FNDA:1,(anonymous_11) 46 | FNDA:1,(anonymous_12) 47 | FNDA:1,(anonymous_13) 48 | FNDA:5,(anonymous_14) 49 | FNDA:1,(anonymous_15) 50 | FNDA:2,(anonymous_16) 51 | FNDA:1,(anonymous_17) 52 | FNDA:1,(anonymous_18) 53 | FNDA:2,(anonymous_19) 54 | FNDA:4,(anonymous_20) 55 | FNDA:4,(anonymous_21) 56 | FNDA:1,(anonymous_22) 57 | FNDA:2,(anonymous_23) 58 | FNDA:4,(anonymous_24) 59 | FNDA:1,(anonymous_25) 60 | FNDA:2,(anonymous_26) 61 | FNDA:4,(anonymous_27) 62 | FNDA:1,(anonymous_28) 63 | FNDA:2,(anonymous_29) 64 | FNDA:4,(anonymous_30) 65 | DA:3,1 66 | DA:4,1 67 | DA:5,1 68 | DA:7,1 69 | DA:14,1 70 | DA:18,1 71 | DA:25,1 72 | DA:29,1 73 | DA:34,1 74 | DA:41,1 75 | DA:45,1 76 | DA:52,1 77 | DA:60,1 78 | DA:65,1 79 | DA:66,1 80 | DA:67,4 81 | DA:69,1 82 | DA:72,1 83 | DA:73,1 84 | DA:74,1 85 | DA:76,1 86 | DA:79,1 87 | DA:80,1 88 | DA:81,4 89 | DA:83,1 90 | DA:86,1 91 | DA:87,1 92 | DA:88,4 93 | DA:90,1 94 | DA:93,1 95 | DA:94,1 96 | DA:95,1 97 | DA:97,1 98 | DA:100,1 99 | DA:101,1 100 | DA:102,1 101 | DA:104,1 102 | DA:107,1 103 | DA:108,1 104 | DA:109,5 105 | DA:111,1 106 | DA:114,1 107 | DA:115,1 108 | DA:116,2 109 | DA:118,1 110 | DA:119,1 111 | DA:121,1 112 | DA:124,1 113 | DA:125,1 114 | DA:126,2 115 | DA:128,1 116 | DA:129,4 117 | DA:131,1 118 | DA:132,4 119 | DA:134,1 120 | DA:137,1 121 | DA:138,1 122 | DA:139,2 123 | DA:141,1 124 | DA:142,4 125 | DA:144,1 126 | DA:147,1 127 | DA:148,1 128 | DA:149,2 129 | DA:151,1 130 | DA:152,4 131 | DA:154,1 132 | DA:157,1 133 | DA:158,1 134 | DA:159,2 135 | DA:161,1 136 | DA:162,4 137 | DA:164,1 138 | LF:73 139 | LH:73 140 | BRDA:102,1,0,1 141 | BRDA:102,1,1,0 142 | BRF:2 143 | BRH:1 144 | end_of_record 145 | TN: 146 | SF:/Users/richard/src/doi-regex/index.js 147 | FN:20,(anonymous_1) 148 | FN:26,(anonymous_2) 149 | FN:33,(anonymous_3) 150 | FN:45,(anonymous_4) 151 | FN:51,(anonymous_5) 152 | FNF:5 153 | FNH:5 154 | FNDA:37,(anonymous_1) 155 | FNDA:18,(anonymous_2) 156 | FNDA:6,(anonymous_3) 157 | FNDA:7,(anonymous_4) 158 | FNDA:13,(anonymous_5) 159 | DA:17,1 160 | DA:18,1 161 | DA:20,1 162 | DA:21,37 163 | DA:22,37 164 | DA:26,1 165 | DA:27,18 166 | DA:32,18 167 | DA:33,18 168 | DA:34,6 169 | DA:35,6 170 | DA:37,18 171 | DA:38,18 172 | DA:39,18 173 | DA:40,18 174 | DA:42,18 175 | DA:45,1 176 | DA:46,7 177 | DA:47,7 178 | DA:51,1 179 | DA:52,13 180 | DA:53,13 181 | LF:22 182 | LH:22 183 | BRDA:21,1,0,37 184 | BRDA:21,1,1,22 185 | BRDA:22,2,0,9 186 | BRDA:22,2,1,28 187 | BRDA:27,3,0,0 188 | BRDA:27,3,1,18 189 | BRDA:38,4,0,18 190 | BRDA:38,4,1,0 191 | BRDA:40,5,0,6 192 | BRDA:40,5,1,12 193 | BRDA:46,6,0,7 194 | BRDA:46,6,1,1 195 | BRDA:47,7,0,6 196 | BRDA:47,7,1,1 197 | BRDA:52,8,0,13 198 | BRDA:52,8,1,3 199 | BRDA:53,9,0,10 200 | BRDA:53,9,1,3 201 | BRF:18 202 | BRH:16 203 | end_of_record 204 | -------------------------------------------------------------------------------- /coverage/lcov-report/doi-regex/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for doi-regex/ 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | all files doi-regex/ 20 |

21 |
22 |
23 | 95.65% 24 | Statements 25 | 22/23 26 |
27 |
28 | 88.89% 29 | Branches 30 | 16/18 31 |
32 |
33 | 100% 34 | Functions 35 | 5/5 36 |
37 |
38 | 100% 39 | Lines 40 | 22/22 41 |
42 |
43 |
44 |
45 |
46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |
FileStatementsBranchesFunctionsLines
index.js
95.65%22/2388.89%16/18100%5/5100%22/22
76 |
77 |
78 | 82 | 83 | 84 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /coverage/lcov-report/doi-regex/spec/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for doi-regex/spec/ 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | all files doi-regex/spec/ 20 |

21 |
22 |
23 | 100% 24 | Statements 25 | 73/73 26 |
27 |
28 | 50% 29 | Branches 30 | 1/2 31 |
32 |
33 | 100% 34 | Functions 35 | 30/30 36 |
37 |
38 | 100% 39 | Lines 40 | 73/73 41 |
42 |
43 |
44 |
45 |
46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |
FileStatementsBranchesFunctionsLines
test.js
100%73/7350%1/2100%30/30100%73/73
76 |
77 |
78 | 82 | 83 | 84 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /coverage/lcov-report/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for All files 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | / 20 |

21 |
22 |
23 | 98.96% 24 | Statements 25 | 95/96 26 |
27 |
28 | 85% 29 | Branches 30 | 17/20 31 |
32 |
33 | 100% 34 | Functions 35 | 35/35 36 |
37 |
38 | 100% 39 | Lines 40 | 95/95 41 |
42 |
43 |
44 |
45 |
46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 |
FileStatementsBranchesFunctionsLines
doi-regex/
95.65%22/2388.89%16/18100%5/5100%22/22
doi-regex/spec/
100%73/7350%1/2100%30/30100%73/73
89 |
90 |
91 | 95 | 96 | 97 | 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /spec/test.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | var test = require('tape') 4 | var _ = require('lodash') 5 | var doiRegex = require('../.') 6 | 7 | var doi = [ 8 | '10.0001/journal.pone.000001', 9 | '10.0001/journal/pone.0011111', 10 | '10.0001.112/journal.pone.0011021', 11 | '10.0001/issn.10001', 12 | '10.10.123/456' 13 | ] 14 | 15 | var doiOlderFormat = [ 16 | '10.1002/(SICI)1096-8644(199808)106:4<483::AID-AJPA4>3.0.CO;2-K' // one of 300K DOIs from Wiley - see https://www.crossref.org/blog/dois-and-matching-regular-expressions/ for more info 17 | ] 18 | 19 | var doiNot = [ 20 | '10..1000/journal.pone.0011111', 21 | '1.1/1.1', 22 | '10/134980', 23 | '10.001/001#00' 24 | ] 25 | 26 | var doiDeclared = [ 27 | 'doi:10.1000/journal.pone.0011111', 28 | ] 29 | 30 | var doiResolvePathWithoutProtocol = [ 31 | 'dx.doi.org/10.1016/j.neuron.2014.09.004', 32 | 'doi.org/10.1016/j.neuron.2014.09.004' 33 | ] 34 | 35 | var doiResolvePathWithProtocol = [ 36 | 'http://dx.doi.org/10.1016/j.neuron.2014.09.004', 37 | 'https://dx.doi.org/10.1016/j.neuron.2014.09.004', 38 | 'http://doi.org/10.1016/j.neuron.2014.09.004', 39 | 'https://doi.org/10.1016/j.neuron.2014.09.004' 40 | ] 41 | 42 | var doiResolvePathInvalid = [ 43 | 'dxsdfas.doi.org/10.1016/j.neuron.2014.09.004' 44 | ] 45 | 46 | var doiResolvePathWithProtocolInvalid = [ 47 | 'httpp://dx.doi.org/10.1016/j.neuron.2014.09.004', 48 | 'httpp://doi.org/10.1016/j.neuron.2014.09.004', 49 | 'ftp://dx.doi.org/10.1016/j.neuron.2014.09.004', 50 | 'ftp://doi.org/10.1016/j.neuron.2014.09.004', 51 | ] 52 | 53 | var doiNotDeclared = [ 54 | 'do:10.1000/journal.pone.0011111', 55 | 'doi:10..1000/journal.pone.0011111', 56 | 'DO:10.1000/journal.pone.0011111', 57 | ':10.1000/journal.pone.0011111', 58 | '10.1000/journal.pone.0011111' 59 | ] 60 | 61 | var doiGroups = [ 62 | '10.1000/journal.pone.0011111.a001', 63 | 'doi:10.1000/journal.pone.0011111.a001' 64 | ] 65 | 66 | test('exact DOIs as passing', function (t) { 67 | _(doi).each(function (el) { 68 | t.assert(doiRegex({exact: true}).test(el), el) 69 | }) 70 | t.end() 71 | }) 72 | 73 | test('older format DOIs as passing', function (t) { 74 | _(doiOlderFormat).each(function (el) { 75 | t.assert(doiRegex({exact: true}).test(el), el) 76 | }) 77 | t.end() 78 | }) 79 | 80 | test('embeded DOIs as passing', function (t) { 81 | _(doi).each(function (el) { 82 | t.assert(doiRegex().exec('foo' + el)[0] === el, el) 83 | }) 84 | t.end() 85 | }) 86 | 87 | test('non-exact DOIs as failing', function (t) { 88 | _(doiNot).each(function (el) { 89 | t.assert(!doiRegex({exact: true}).test(el), el) 90 | }) 91 | t.end() 92 | }) 93 | 94 | test('DOI declared as passing', function (t) { 95 | _(doiDeclared).each(function (el) { 96 | t.assert(doiRegex.declared({exact: true}).test(el), el) 97 | }) 98 | t.end() 99 | }) 100 | 101 | test('DOI declared embeded as passing', function (t) { 102 | _(doiDeclared).each(function (el) { 103 | t.assert((doiRegex.declared().exec('foo' + el) || [])[0] === el, el) 104 | }) 105 | t.end() 106 | }) 107 | 108 | test('DOI not declared as failing', function (t) { 109 | _(doiNotDeclared).each(function (el) { 110 | t.assert(!doiRegex.declared({exact: true}).test(el), el) 111 | }) 112 | t.end() 113 | }) 114 | 115 | test('DOI with resolve path as passing', function (t) { 116 | _(doiResolvePathWithoutProtocol).each(function (el) { 117 | t.assert(doiRegex.resolvePath().test(el), el) 118 | }) 119 | _(doiResolvePathInvalid).each(function (el) { 120 | t.assert(!doiRegex.resolvePath().test(el), el) 121 | }) 122 | t.end() 123 | }) 124 | 125 | test('DOI with resolve path and protocol mandatory as passing', function (t) { 126 | _(doiResolvePathWithoutProtocol).each(function (el) { 127 | t.assert(!doiRegex.resolvePath({protocol: true}).test(el), el) 128 | }) 129 | _(doiResolvePathWithProtocol).each(function (el) { 130 | t.assert(doiRegex.resolvePath({protocol: true}).test(el), el) 131 | }) 132 | _(doiResolvePathWithProtocolInvalid).each(function (el) { 133 | t.assert(!doiRegex.resolvePath({protocol: true}).test(el), el) 134 | }) 135 | t.end() 136 | }) 137 | 138 | test('DOI group catching returns original', function (t) { 139 | _(doiGroups).each(function (el) { 140 | t.assert(doiRegex.groups(el)[0] === el, el) 141 | }) 142 | _(doi).each(function (el) { 143 | t.assert(doiRegex.groups(el)[0] === el, el) 144 | }) 145 | t.end() 146 | }) 147 | 148 | test('DOI group catching returns DOI', function (t) { 149 | _(doiGroups).each(function (el) { 150 | t.assert(doiRegex(doiRegex.groups(el)[1]), el) 151 | }) 152 | _(doi).each(function (el) { 153 | t.assert(doiRegex(doiRegex.groups(el)[1]), el) 154 | }) 155 | t.end() 156 | }) 157 | 158 | test('DOI group catching returns extension', function (t) { 159 | _(doiGroups).each(function (el) { 160 | t.assert(doiRegex.groups(el)[2].length === 5, el) 161 | }) 162 | _(doi).each(function (el) { 163 | t.assert(doiRegex.groups(el)[2].length === 0, el) 164 | }) 165 | t.end() 166 | }) 167 | -------------------------------------------------------------------------------- /coverage/lcov-report/sorter.js: -------------------------------------------------------------------------------- 1 | var addSorting = (function () { 2 | "use strict"; 3 | var cols, 4 | currentSort = { 5 | index: 0, 6 | desc: false 7 | }; 8 | 9 | // returns the summary table element 10 | function getTable() { return document.querySelector('.coverage-summary'); } 11 | // returns the thead element of the summary table 12 | function getTableHeader() { return getTable().querySelector('thead tr'); } 13 | // returns the tbody element of the summary table 14 | function getTableBody() { return getTable().querySelector('tbody'); } 15 | // returns the th element for nth column 16 | function getNthColumn(n) { return getTableHeader().querySelectorAll('th')[n]; } 17 | 18 | // loads all columns 19 | function loadColumns() { 20 | var colNodes = getTableHeader().querySelectorAll('th'), 21 | colNode, 22 | cols = [], 23 | col, 24 | i; 25 | 26 | for (i = 0; i < colNodes.length; i += 1) { 27 | colNode = colNodes[i]; 28 | col = { 29 | key: colNode.getAttribute('data-col'), 30 | sortable: !colNode.getAttribute('data-nosort'), 31 | type: colNode.getAttribute('data-type') || 'string' 32 | }; 33 | cols.push(col); 34 | if (col.sortable) { 35 | col.defaultDescSort = col.type === 'number'; 36 | colNode.innerHTML = colNode.innerHTML + ''; 37 | } 38 | } 39 | return cols; 40 | } 41 | // attaches a data attribute to every tr element with an object 42 | // of data values keyed by column name 43 | function loadRowData(tableRow) { 44 | var tableCols = tableRow.querySelectorAll('td'), 45 | colNode, 46 | col, 47 | data = {}, 48 | i, 49 | val; 50 | for (i = 0; i < tableCols.length; i += 1) { 51 | colNode = tableCols[i]; 52 | col = cols[i]; 53 | val = colNode.getAttribute('data-value'); 54 | if (col.type === 'number') { 55 | val = Number(val); 56 | } 57 | data[col.key] = val; 58 | } 59 | return data; 60 | } 61 | // loads all row data 62 | function loadData() { 63 | var rows = getTableBody().querySelectorAll('tr'), 64 | i; 65 | 66 | for (i = 0; i < rows.length; i += 1) { 67 | rows[i].data = loadRowData(rows[i]); 68 | } 69 | } 70 | // sorts the table using the data for the ith column 71 | function sortByIndex(index, desc) { 72 | var key = cols[index].key, 73 | sorter = function (a, b) { 74 | a = a.data[key]; 75 | b = b.data[key]; 76 | return a < b ? -1 : a > b ? 1 : 0; 77 | }, 78 | finalSorter = sorter, 79 | tableBody = document.querySelector('.coverage-summary tbody'), 80 | rowNodes = tableBody.querySelectorAll('tr'), 81 | rows = [], 82 | i; 83 | 84 | if (desc) { 85 | finalSorter = function (a, b) { 86 | return -1 * sorter(a, b); 87 | }; 88 | } 89 | 90 | for (i = 0; i < rowNodes.length; i += 1) { 91 | rows.push(rowNodes[i]); 92 | tableBody.removeChild(rowNodes[i]); 93 | } 94 | 95 | rows.sort(finalSorter); 96 | 97 | for (i = 0; i < rows.length; i += 1) { 98 | tableBody.appendChild(rows[i]); 99 | } 100 | } 101 | // removes sort indicators for current column being sorted 102 | function removeSortIndicators() { 103 | var col = getNthColumn(currentSort.index), 104 | cls = col.className; 105 | 106 | cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); 107 | col.className = cls; 108 | } 109 | // adds sort indicators for current column being sorted 110 | function addSortIndicators() { 111 | getNthColumn(currentSort.index).className += currentSort.desc ? ' sorted-desc' : ' sorted'; 112 | } 113 | // adds event listeners for all sorter widgets 114 | function enableUI() { 115 | var i, 116 | el, 117 | ithSorter = function ithSorter(i) { 118 | var col = cols[i]; 119 | 120 | return function () { 121 | var desc = col.defaultDescSort; 122 | 123 | if (currentSort.index === i) { 124 | desc = !currentSort.desc; 125 | } 126 | sortByIndex(i, desc); 127 | removeSortIndicators(); 128 | currentSort.index = i; 129 | currentSort.desc = desc; 130 | addSortIndicators(); 131 | }; 132 | }; 133 | for (i =0 ; i < cols.length; i += 1) { 134 | if (cols[i].sortable) { 135 | // add the click event handler on the th so users 136 | // dont have to click on those tiny arrows 137 | el = getNthColumn(i).querySelector('.sorter').parentElement; 138 | if (el.addEventListener) { 139 | el.addEventListener('click', ithSorter(i)); 140 | } else { 141 | el.attachEvent('onclick', ithSorter(i)); 142 | } 143 | } 144 | } 145 | } 146 | // adds sorting functionality to the UI 147 | return function () { 148 | if (!getTable()) { 149 | return; 150 | } 151 | cols = loadColumns(); 152 | loadData(cols); 153 | addSortIndicators(); 154 | enableUI(); 155 | }; 156 | })(); 157 | 158 | window.addEventListener('load', addSorting); 159 | -------------------------------------------------------------------------------- /coverage/lcov-report/base.css: -------------------------------------------------------------------------------- 1 | body, html { 2 | margin:0; padding: 0; 3 | height: 100%; 4 | } 5 | body { 6 | font-family: Helvetica Neue, Helvetica, Arial; 7 | font-size: 14px; 8 | color:#333; 9 | } 10 | .small { font-size: 12px; } 11 | *, *:after, *:before { 12 | -webkit-box-sizing:border-box; 13 | -moz-box-sizing:border-box; 14 | box-sizing:border-box; 15 | } 16 | h1 { font-size: 20px; margin: 0;} 17 | h2 { font-size: 14px; } 18 | pre { 19 | font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; 20 | margin: 0; 21 | padding: 0; 22 | -moz-tab-size: 2; 23 | -o-tab-size: 2; 24 | tab-size: 2; 25 | } 26 | a { color:#0074D9; text-decoration:none; } 27 | a:hover { text-decoration:underline; } 28 | .strong { font-weight: bold; } 29 | .space-top1 { padding: 10px 0 0 0; } 30 | .pad2y { padding: 20px 0; } 31 | .pad1y { padding: 10px 0; } 32 | .pad2x { padding: 0 20px; } 33 | .pad2 { padding: 20px; } 34 | .pad1 { padding: 10px; } 35 | .space-left2 { padding-left:55px; } 36 | .space-right2 { padding-right:20px; } 37 | .center { text-align:center; } 38 | .clearfix { display:block; } 39 | .clearfix:after { 40 | content:''; 41 | display:block; 42 | height:0; 43 | clear:both; 44 | visibility:hidden; 45 | } 46 | .fl { float: left; } 47 | @media only screen and (max-width:640px) { 48 | .col3 { width:100%; max-width:100%; } 49 | .hide-mobile { display:none!important; } 50 | } 51 | 52 | .quiet { 53 | color: #7f7f7f; 54 | color: rgba(0,0,0,0.5); 55 | } 56 | .quiet a { opacity: 0.7; } 57 | 58 | .fraction { 59 | font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; 60 | font-size: 10px; 61 | color: #555; 62 | background: #E8E8E8; 63 | padding: 4px 5px; 64 | border-radius: 3px; 65 | vertical-align: middle; 66 | } 67 | 68 | div.path a:link, div.path a:visited { color: #333; } 69 | table.coverage { 70 | border-collapse: collapse; 71 | margin: 10px 0 0 0; 72 | padding: 0; 73 | } 74 | 75 | table.coverage td { 76 | margin: 0; 77 | padding: 0; 78 | vertical-align: top; 79 | } 80 | table.coverage td.line-count { 81 | text-align: right; 82 | padding: 0 5px 0 20px; 83 | } 84 | table.coverage td.line-coverage { 85 | text-align: right; 86 | padding-right: 10px; 87 | min-width:20px; 88 | } 89 | 90 | table.coverage td span.cline-any { 91 | display: inline-block; 92 | padding: 0 5px; 93 | width: 100%; 94 | } 95 | .missing-if-branch { 96 | display: inline-block; 97 | margin-right: 5px; 98 | border-radius: 3px; 99 | position: relative; 100 | padding: 0 4px; 101 | background: #333; 102 | color: yellow; 103 | } 104 | 105 | .skip-if-branch { 106 | display: none; 107 | margin-right: 10px; 108 | position: relative; 109 | padding: 0 4px; 110 | background: #ccc; 111 | color: white; 112 | } 113 | .missing-if-branch .typ, .skip-if-branch .typ { 114 | color: inherit !important; 115 | } 116 | .coverage-summary { 117 | border-collapse: collapse; 118 | width: 100%; 119 | } 120 | .coverage-summary tr { border-bottom: 1px solid #bbb; } 121 | .keyline-all { border: 1px solid #ddd; } 122 | .coverage-summary td, .coverage-summary th { padding: 10px; } 123 | .coverage-summary tbody { border: 1px solid #bbb; } 124 | .coverage-summary td { border-right: 1px solid #bbb; } 125 | .coverage-summary td:last-child { border-right: none; } 126 | .coverage-summary th { 127 | text-align: left; 128 | font-weight: normal; 129 | white-space: nowrap; 130 | } 131 | .coverage-summary th.file { border-right: none !important; } 132 | .coverage-summary th.pct { } 133 | .coverage-summary th.pic, 134 | .coverage-summary th.abs, 135 | .coverage-summary td.pct, 136 | .coverage-summary td.abs { text-align: right; } 137 | .coverage-summary td.file { white-space: nowrap; } 138 | .coverage-summary td.pic { min-width: 120px !important; } 139 | .coverage-summary tfoot td { } 140 | 141 | .coverage-summary .sorter { 142 | height: 10px; 143 | width: 7px; 144 | display: inline-block; 145 | margin-left: 0.5em; 146 | background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; 147 | } 148 | .coverage-summary .sorted .sorter { 149 | background-position: 0 -20px; 150 | } 151 | .coverage-summary .sorted-desc .sorter { 152 | background-position: 0 -10px; 153 | } 154 | .status-line { height: 10px; } 155 | /* dark red */ 156 | .red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } 157 | .low .chart { border:1px solid #C21F39 } 158 | /* medium red */ 159 | .cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } 160 | /* light red */ 161 | .low, .cline-no { background:#FCE1E5 } 162 | /* light green */ 163 | .high, .cline-yes { background:rgb(230,245,208) } 164 | /* medium green */ 165 | .cstat-yes { background:rgb(161,215,106) } 166 | /* dark green */ 167 | .status-line.high, .high .cover-fill { background:rgb(77,146,33) } 168 | .high .chart { border:1px solid rgb(77,146,33) } 169 | /* dark yellow (gold) */ 170 | .medium .chart { border:1px solid #f9cd0b; } 171 | .status-line.medium, .medium .cover-fill { background: #f9cd0b; } 172 | /* light yellow */ 173 | .medium { background: #fff4c2; } 174 | /* light gray */ 175 | span.cline-neutral { background: #eaeaea; } 176 | 177 | .cbranch-no { background: yellow !important; color: #111; } 178 | 179 | .cstat-skip { background: #ddd; color: #111; } 180 | .fstat-skip { background: #ddd; color: #111 !important; } 181 | .cbranch-skip { background: #ddd !important; color: #111; } 182 | 183 | 184 | .cover-fill, .cover-empty { 185 | display:inline-block; 186 | height: 12px; 187 | } 188 | .chart { 189 | line-height: 0; 190 | } 191 | .cover-empty { 192 | background: white; 193 | } 194 | .cover-full { 195 | border-right: none !important; 196 | } 197 | pre.prettyprint { 198 | border: none !important; 199 | padding: 0 !important; 200 | margin: 0 !important; 201 | } 202 | .com { color: #999 !important; } 203 | .ignore-none { color: #999; font-weight: normal; } 204 | 205 | .wrapper { 206 | min-height: 100%; 207 | height: auto !important; 208 | height: 100%; 209 | margin: 0 auto -48px; 210 | } 211 | .footer, .push { 212 | height: 48px; 213 | } 214 | -------------------------------------------------------------------------------- /coverage/lcov-report/doi-regex/index.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for doi-regex/index.js 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | all files / doi-regex/ index.js 20 |

21 |
22 |
23 | 95.65% 24 | Statements 25 | 22/23 26 |
27 |
28 | 88.89% 29 | Branches 30 | 16/18 31 |
32 |
33 | 100% 34 | Functions 35 | 5/5 36 |
37 |
38 | 100% 39 | Lines 40 | 22/22 41 |
42 |
43 |
44 |
45 |

 46 | 
212 | 
1 47 | 2 48 | 3 49 | 4 50 | 5 51 | 6 52 | 7 53 | 8 54 | 9 55 | 10 56 | 11 57 | 12 58 | 13 59 | 14 60 | 15 61 | 16 62 | 17 63 | 18 64 | 19 65 | 20 66 | 21 67 | 22 68 | 23 69 | 24 70 | 25 71 | 26 72 | 27 73 | 28 74 | 29 75 | 30 76 | 31 77 | 32 78 | 33 79 | 34 80 | 35 81 | 36 82 | 37 83 | 38 84 | 39 85 | 40 86 | 41 87 | 42 88 | 43 89 | 44 90 | 45 91 | 46 92 | 47 93 | 48 94 | 49 95 | 50 96 | 51 97 | 52 98 | 53 99 | 54 100 | 55 101 | 56  102 |   103 |   104 |   105 |   106 |   107 |   108 |   109 |   110 |   111 |   112 |   113 |   114 |   115 |   116 |   117 | 118 | 119 |   120 | 121 | 37× 122 | 37× 123 |   124 |   125 |   126 | 127 | 18× 128 |   129 |   130 |   131 |   132 | 18× 133 | 18× 134 | 135 | 136 |   137 | 18× 138 | 18× 139 | 18× 140 | 18× 141 |   142 | 18× 143 |   144 |   145 | 146 | 147 | 148 |   149 |   150 |   151 | 152 | 13× 153 | 13× 154 |   155 |   156 |  
'use strict'
157 |  
158 | /**
159 |  * Parts of a DOI:
160 |  * Directory Identifier: 10
161 |  * Registrant code: . + [0-9]{4,}
162 |  * Registrant subdivision (optional): . + [0-9]+
163 |  * Suffix: / + any character, case insensitive for ASCII chars (but capitalised
164 |  *   in the registry), with some characters that _should_ be escaped.
165 |  *   Recommended encoding: "{}^[]`|\\&\/\'<>
166 |  *   Mandatory encoding: %"#? (and space)
167 |  * From: http://www.doi.org/doi_handbook/2_Numbering.html#2.2
168 |  */
169 |  
170 | // TODO Capture final segment for fragments
171 | // (\\.[a-zA-Z]{1}[0-9]{3})?
172 | var doiRegex = '(10[.][0-9]{4,}(?:[.][0-9]+)*/(?:(?![%"#? ])\\S)+)'
173 | var doiTextPrefix = 'doi\\:'
174 |  
175 | var doi = module.exports = function (opts) {
176 |   opts = opts || {}
177 |   return opts.exact ? new RegExp('(?:^' + doiRegex + '$)') :
178 |                       new RegExp('(?:' + doiRegex + ')', 'g')
179 | }
180 |  
181 | doi.groups = function (str) {
182 |   Iif (!str) { return }
183 |   // Javascript fails at lookaheads for optional groups. This circumvents that
184 |   // problem by just automatically removing and saving suffixes if they are in
185 |   // as specific format - .a000 is the format used by PLoS, but this may need
186 |   // to be filled out.
187 |   var suffixes = []
188 |   var newStr = str.replace(/\.[a-zA-Z]{1}[0-9]{3}$/g, function (s) {
189 |     suffixes.push(s)
190 |     return ''
191 |   })
192 |   var match = doi().exec(newStr)
193 |   Eif (match) {
194 |     match[0] = str
195 |     match.push((suffixes.length) ? suffixes[0] : '')
196 |   }
197 |   return match
198 | }
199 |  
200 | doi.declared = function (opts) {
201 |   opts = opts || {}
202 |   return opts.exact ? new RegExp('^' + doiTextPrefix + doiRegex + '$') :
203 |                       new RegExp(doiTextPrefix + doiRegex, 'g')
204 | }
205 |  
206 | doi.resolvePath = function (opts) {
207 |   opts = opts || {}
208 |   return opts.protocol ? new RegExp('^http(s)?\\://(dx\\.)?doi\\.org/' + doiRegex + '$') :
209 |     new RegExp('^(http(s)?\\://)?(dx\\.)?doi\\.org/' + doiRegex + '$')
210 | }
211 |  
213 |
214 |
215 | 219 | 220 | 221 | 228 | 229 | 230 | 231 | -------------------------------------------------------------------------------- /coverage/coverage.json: -------------------------------------------------------------------------------- 1 | {"/Users/richard/src/doi-regex/spec/test.js":{"path":"/Users/richard/src/doi-regex/spec/test.js","s":{"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":1,"13":1,"14":1,"15":1,"16":4,"17":1,"18":1,"19":1,"20":1,"21":1,"22":1,"23":1,"24":4,"25":1,"26":1,"27":1,"28":4,"29":1,"30":1,"31":1,"32":1,"33":1,"34":1,"35":1,"36":1,"37":1,"38":1,"39":1,"40":5,"41":1,"42":1,"43":1,"44":2,"45":1,"46":1,"47":1,"48":1,"49":1,"50":2,"51":1,"52":4,"53":1,"54":4,"55":1,"56":1,"57":1,"58":2,"59":1,"60":4,"61":1,"62":1,"63":1,"64":2,"65":1,"66":4,"67":1,"68":1,"69":1,"70":2,"71":1,"72":4,"73":1},"b":{"1":[1,0]},"f":{"1":1,"2":4,"3":1,"4":1,"5":1,"6":4,"7":1,"8":4,"9":1,"10":1,"11":1,"12":1,"13":1,"14":5,"15":1,"16":2,"17":1,"18":1,"19":2,"20":4,"21":4,"22":1,"23":2,"24":4,"25":1,"26":2,"27":4,"28":1,"29":2,"30":4},"fnMap":{"1":{"name":"(anonymous_1)","line":65,"loc":{"start":{"line":65,"column":30},"end":{"line":65,"column":43}}},"2":{"name":"(anonymous_2)","line":66,"loc":{"start":{"line":66,"column":14},"end":{"line":66,"column":28}}},"3":{"name":"(anonymous_3)","line":72,"loc":{"start":{"line":72,"column":37},"end":{"line":72,"column":50}}},"4":{"name":"(anonymous_4)","line":73,"loc":{"start":{"line":73,"column":25},"end":{"line":73,"column":39}}},"5":{"name":"(anonymous_5)","line":79,"loc":{"start":{"line":79,"column":32},"end":{"line":79,"column":45}}},"6":{"name":"(anonymous_6)","line":80,"loc":{"start":{"line":80,"column":14},"end":{"line":80,"column":28}}},"7":{"name":"(anonymous_7)","line":86,"loc":{"start":{"line":86,"column":34},"end":{"line":86,"column":47}}},"8":{"name":"(anonymous_8)","line":87,"loc":{"start":{"line":87,"column":17},"end":{"line":87,"column":31}}},"9":{"name":"(anonymous_9)","line":93,"loc":{"start":{"line":93,"column":32},"end":{"line":93,"column":45}}},"10":{"name":"(anonymous_10)","line":94,"loc":{"start":{"line":94,"column":22},"end":{"line":94,"column":36}}},"11":{"name":"(anonymous_11)","line":100,"loc":{"start":{"line":100,"column":40},"end":{"line":100,"column":53}}},"12":{"name":"(anonymous_12)","line":101,"loc":{"start":{"line":101,"column":22},"end":{"line":101,"column":36}}},"13":{"name":"(anonymous_13)","line":107,"loc":{"start":{"line":107,"column":36},"end":{"line":107,"column":49}}},"14":{"name":"(anonymous_14)","line":108,"loc":{"start":{"line":108,"column":25},"end":{"line":108,"column":39}}},"15":{"name":"(anonymous_15)","line":114,"loc":{"start":{"line":114,"column":41},"end":{"line":114,"column":54}}},"16":{"name":"(anonymous_16)","line":115,"loc":{"start":{"line":115,"column":40},"end":{"line":115,"column":54}}},"17":{"name":"(anonymous_17)","line":118,"loc":{"start":{"line":118,"column":32},"end":{"line":118,"column":46}}},"18":{"name":"(anonymous_18)","line":124,"loc":{"start":{"line":124,"column":64},"end":{"line":124,"column":77}}},"19":{"name":"(anonymous_19)","line":125,"loc":{"start":{"line":125,"column":40},"end":{"line":125,"column":54}}},"20":{"name":"(anonymous_20)","line":128,"loc":{"start":{"line":128,"column":37},"end":{"line":128,"column":51}}},"21":{"name":"(anonymous_21)","line":131,"loc":{"start":{"line":131,"column":44},"end":{"line":131,"column":58}}},"22":{"name":"(anonymous_22)","line":137,"loc":{"start":{"line":137,"column":44},"end":{"line":137,"column":57}}},"23":{"name":"(anonymous_23)","line":138,"loc":{"start":{"line":138,"column":20},"end":{"line":138,"column":34}}},"24":{"name":"(anonymous_24)","line":141,"loc":{"start":{"line":141,"column":14},"end":{"line":141,"column":28}}},"25":{"name":"(anonymous_25)","line":147,"loc":{"start":{"line":147,"column":39},"end":{"line":147,"column":52}}},"26":{"name":"(anonymous_26)","line":148,"loc":{"start":{"line":148,"column":20},"end":{"line":148,"column":34}}},"27":{"name":"(anonymous_27)","line":151,"loc":{"start":{"line":151,"column":14},"end":{"line":151,"column":28}}},"28":{"name":"(anonymous_28)","line":157,"loc":{"start":{"line":157,"column":45},"end":{"line":157,"column":58}}},"29":{"name":"(anonymous_29)","line":158,"loc":{"start":{"line":158,"column":20},"end":{"line":158,"column":34}}},"30":{"name":"(anonymous_30)","line":161,"loc":{"start":{"line":161,"column":14},"end":{"line":161,"column":28}}}},"statementMap":{"1":{"start":{"line":3,"column":0},"end":{"line":3,"column":26}},"2":{"start":{"line":4,"column":0},"end":{"line":4,"column":25}},"3":{"start":{"line":5,"column":0},"end":{"line":5,"column":30}},"4":{"start":{"line":7,"column":0},"end":{"line":12,"column":1}},"5":{"start":{"line":14,"column":0},"end":{"line":16,"column":1}},"6":{"start":{"line":18,"column":0},"end":{"line":23,"column":1}},"7":{"start":{"line":25,"column":0},"end":{"line":27,"column":1}},"8":{"start":{"line":29,"column":0},"end":{"line":32,"column":1}},"9":{"start":{"line":34,"column":0},"end":{"line":39,"column":1}},"10":{"start":{"line":41,"column":0},"end":{"line":43,"column":1}},"11":{"start":{"line":45,"column":0},"end":{"line":50,"column":1}},"12":{"start":{"line":52,"column":0},"end":{"line":58,"column":1}},"13":{"start":{"line":60,"column":0},"end":{"line":63,"column":1}},"14":{"start":{"line":65,"column":0},"end":{"line":70,"column":2}},"15":{"start":{"line":66,"column":2},"end":{"line":68,"column":4}},"16":{"start":{"line":67,"column":4},"end":{"line":67,"column":50}},"17":{"start":{"line":69,"column":2},"end":{"line":69,"column":9}},"18":{"start":{"line":72,"column":0},"end":{"line":77,"column":2}},"19":{"start":{"line":73,"column":2},"end":{"line":75,"column":4}},"20":{"start":{"line":74,"column":4},"end":{"line":74,"column":50}},"21":{"start":{"line":76,"column":2},"end":{"line":76,"column":9}},"22":{"start":{"line":79,"column":0},"end":{"line":84,"column":2}},"23":{"start":{"line":80,"column":2},"end":{"line":82,"column":4}},"24":{"start":{"line":81,"column":4},"end":{"line":81,"column":55}},"25":{"start":{"line":83,"column":2},"end":{"line":83,"column":9}},"26":{"start":{"line":86,"column":0},"end":{"line":91,"column":2}},"27":{"start":{"line":87,"column":2},"end":{"line":89,"column":4}},"28":{"start":{"line":88,"column":4},"end":{"line":88,"column":51}},"29":{"start":{"line":90,"column":2},"end":{"line":90,"column":9}},"30":{"start":{"line":93,"column":0},"end":{"line":98,"column":2}},"31":{"start":{"line":94,"column":2},"end":{"line":96,"column":4}},"32":{"start":{"line":95,"column":4},"end":{"line":95,"column":59}},"33":{"start":{"line":97,"column":2},"end":{"line":97,"column":9}},"34":{"start":{"line":100,"column":0},"end":{"line":105,"column":2}},"35":{"start":{"line":101,"column":2},"end":{"line":103,"column":4}},"36":{"start":{"line":102,"column":4},"end":{"line":102,"column":72}},"37":{"start":{"line":104,"column":2},"end":{"line":104,"column":9}},"38":{"start":{"line":107,"column":0},"end":{"line":112,"column":2}},"39":{"start":{"line":108,"column":2},"end":{"line":110,"column":4}},"40":{"start":{"line":109,"column":4},"end":{"line":109,"column":60}},"41":{"start":{"line":111,"column":2},"end":{"line":111,"column":9}},"42":{"start":{"line":114,"column":0},"end":{"line":122,"column":2}},"43":{"start":{"line":115,"column":2},"end":{"line":117,"column":4}},"44":{"start":{"line":116,"column":4},"end":{"line":116,"column":49}},"45":{"start":{"line":118,"column":2},"end":{"line":120,"column":4}},"46":{"start":{"line":119,"column":4},"end":{"line":119,"column":50}},"47":{"start":{"line":121,"column":2},"end":{"line":121,"column":9}},"48":{"start":{"line":124,"column":0},"end":{"line":135,"column":2}},"49":{"start":{"line":125,"column":2},"end":{"line":127,"column":4}},"50":{"start":{"line":126,"column":4},"end":{"line":126,"column":66}},"51":{"start":{"line":128,"column":2},"end":{"line":130,"column":4}},"52":{"start":{"line":129,"column":4},"end":{"line":129,"column":65}},"53":{"start":{"line":131,"column":2},"end":{"line":133,"column":4}},"54":{"start":{"line":132,"column":4},"end":{"line":132,"column":66}},"55":{"start":{"line":134,"column":2},"end":{"line":134,"column":9}},"56":{"start":{"line":137,"column":0},"end":{"line":145,"column":2}},"57":{"start":{"line":138,"column":2},"end":{"line":140,"column":4}},"58":{"start":{"line":139,"column":4},"end":{"line":139,"column":47}},"59":{"start":{"line":141,"column":2},"end":{"line":143,"column":4}},"60":{"start":{"line":142,"column":4},"end":{"line":142,"column":47}},"61":{"start":{"line":144,"column":2},"end":{"line":144,"column":9}},"62":{"start":{"line":147,"column":0},"end":{"line":155,"column":2}},"63":{"start":{"line":148,"column":2},"end":{"line":150,"column":4}},"64":{"start":{"line":149,"column":4},"end":{"line":149,"column":50}},"65":{"start":{"line":151,"column":2},"end":{"line":153,"column":4}},"66":{"start":{"line":152,"column":4},"end":{"line":152,"column":50}},"67":{"start":{"line":154,"column":2},"end":{"line":154,"column":9}},"68":{"start":{"line":157,"column":0},"end":{"line":165,"column":2}},"69":{"start":{"line":158,"column":2},"end":{"line":160,"column":4}},"70":{"start":{"line":159,"column":4},"end":{"line":159,"column":53}},"71":{"start":{"line":161,"column":2},"end":{"line":163,"column":4}},"72":{"start":{"line":162,"column":4},"end":{"line":162,"column":53}},"73":{"start":{"line":164,"column":2},"end":{"line":164,"column":9}}},"branchMap":{"1":{"line":102,"type":"binary-expr","locations":[{"start":{"line":102,"column":14},"end":{"line":102,"column":50}},{"start":{"line":102,"column":54},"end":{"line":102,"column":56}}]}}},"/Users/richard/src/doi-regex/index.js":{"path":"/Users/richard/src/doi-regex/index.js","s":{"1":1,"2":1,"3":1,"4":37,"5":37,"6":1,"7":18,"8":0,"9":18,"10":18,"11":6,"12":6,"13":18,"14":18,"15":18,"16":18,"17":18,"18":1,"19":7,"20":7,"21":1,"22":13,"23":13},"b":{"1":[37,22],"2":[9,28],"3":[0,18],"4":[18,0],"5":[6,12],"6":[7,1],"7":[6,1],"8":[13,3],"9":[10,3]},"f":{"1":37,"2":18,"3":6,"4":7,"5":13},"fnMap":{"1":{"name":"(anonymous_1)","line":20,"loc":{"start":{"line":20,"column":27},"end":{"line":20,"column":43}}},"2":{"name":"(anonymous_2)","line":26,"loc":{"start":{"line":26,"column":13},"end":{"line":26,"column":28}}},"3":{"name":"(anonymous_3)","line":33,"loc":{"start":{"line":33,"column":54},"end":{"line":33,"column":67}}},"4":{"name":"(anonymous_4)","line":45,"loc":{"start":{"line":45,"column":15},"end":{"line":45,"column":31}}},"5":{"name":"(anonymous_5)","line":51,"loc":{"start":{"line":51,"column":18},"end":{"line":51,"column":34}}}},"statementMap":{"1":{"start":{"line":17,"column":0},"end":{"line":17,"column":67}},"2":{"start":{"line":18,"column":0},"end":{"line":18,"column":28}},"3":{"start":{"line":20,"column":0},"end":{"line":24,"column":1}},"4":{"start":{"line":21,"column":2},"end":{"line":21,"column":19}},"5":{"start":{"line":22,"column":2},"end":{"line":23,"column":61}},"6":{"start":{"line":26,"column":0},"end":{"line":43,"column":1}},"7":{"start":{"line":27,"column":2},"end":{"line":27,"column":22}},"8":{"start":{"line":27,"column":14},"end":{"line":27,"column":21}},"9":{"start":{"line":32,"column":2},"end":{"line":32,"column":19}},"10":{"start":{"line":33,"column":2},"end":{"line":36,"column":4}},"11":{"start":{"line":34,"column":4},"end":{"line":34,"column":20}},"12":{"start":{"line":35,"column":4},"end":{"line":35,"column":13}},"13":{"start":{"line":37,"column":2},"end":{"line":37,"column":32}},"14":{"start":{"line":38,"column":2},"end":{"line":41,"column":3}},"15":{"start":{"line":39,"column":4},"end":{"line":39,"column":18}},"16":{"start":{"line":40,"column":4},"end":{"line":40,"column":52}},"17":{"start":{"line":42,"column":2},"end":{"line":42,"column":14}},"18":{"start":{"line":45,"column":0},"end":{"line":49,"column":1}},"19":{"start":{"line":46,"column":2},"end":{"line":46,"column":19}},"20":{"start":{"line":47,"column":2},"end":{"line":48,"column":63}},"21":{"start":{"line":51,"column":0},"end":{"line":55,"column":1}},"22":{"start":{"line":52,"column":2},"end":{"line":52,"column":19}},"23":{"start":{"line":53,"column":2},"end":{"line":54,"column":70}}},"branchMap":{"1":{"line":21,"type":"binary-expr","locations":[{"start":{"line":21,"column":9},"end":{"line":21,"column":13}},{"start":{"line":21,"column":17},"end":{"line":21,"column":19}}]},"2":{"line":22,"type":"cond-expr","locations":[{"start":{"line":22,"column":22},"end":{"line":22,"column":58}},{"start":{"line":23,"column":22},"end":{"line":23,"column":61}}]},"3":{"line":27,"type":"if","locations":[{"start":{"line":27,"column":2},"end":{"line":27,"column":2}},{"start":{"line":27,"column":2},"end":{"line":27,"column":2}}]},"4":{"line":38,"type":"if","locations":[{"start":{"line":38,"column":2},"end":{"line":38,"column":2}},{"start":{"line":38,"column":2},"end":{"line":38,"column":2}}]},"5":{"line":40,"type":"cond-expr","locations":[{"start":{"line":40,"column":35},"end":{"line":40,"column":46}},{"start":{"line":40,"column":49},"end":{"line":40,"column":51}}]},"6":{"line":46,"type":"binary-expr","locations":[{"start":{"line":46,"column":9},"end":{"line":46,"column":13}},{"start":{"line":46,"column":17},"end":{"line":46,"column":19}}]},"7":{"line":47,"type":"cond-expr","locations":[{"start":{"line":47,"column":22},"end":{"line":47,"column":70}},{"start":{"line":48,"column":22},"end":{"line":48,"column":63}}]},"8":{"line":52,"type":"binary-expr","locations":[{"start":{"line":52,"column":9},"end":{"line":52,"column":13}},{"start":{"line":52,"column":17},"end":{"line":52,"column":19}}]},"9":{"line":53,"type":"cond-expr","locations":[{"start":{"line":53,"column":25},"end":{"line":53,"column":88}},{"start":{"line":54,"column":4},"end":{"line":54,"column":70}}]}}}} -------------------------------------------------------------------------------- /coverage/lcov-report/prettify.js: -------------------------------------------------------------------------------- 1 | window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); 2 | -------------------------------------------------------------------------------- /coverage/lcov-report/doi-regex/spec/test.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for doi-regex/spec/test.js 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | all files / doi-regex/spec/ test.js 20 |

21 |
22 |
23 | 100% 24 | Statements 25 | 73/73 26 |
27 |
28 | 50% 29 | Branches 30 | 1/2 31 |
32 |
33 | 100% 34 | Functions 35 | 30/30 36 |
37 |
38 | 100% 39 | Lines 40 | 73/73 41 |
42 |
43 |
44 |
45 |

 46 | 
542 | 
1 47 | 2 48 | 3 49 | 4 50 | 5 51 | 6 52 | 7 53 | 8 54 | 9 55 | 10 56 | 11 57 | 12 58 | 13 59 | 14 60 | 15 61 | 16 62 | 17 63 | 18 64 | 19 65 | 20 66 | 21 67 | 22 68 | 23 69 | 24 70 | 25 71 | 26 72 | 27 73 | 28 74 | 29 75 | 30 76 | 31 77 | 32 78 | 33 79 | 34 80 | 35 81 | 36 82 | 37 83 | 38 84 | 39 85 | 40 86 | 41 87 | 42 88 | 43 89 | 44 90 | 45 91 | 46 92 | 47 93 | 48 94 | 49 95 | 50 96 | 51 97 | 52 98 | 53 99 | 54 100 | 55 101 | 56 102 | 57 103 | 58 104 | 59 105 | 60 106 | 61 107 | 62 108 | 63 109 | 64 110 | 65 111 | 66 112 | 67 113 | 68 114 | 69 115 | 70 116 | 71 117 | 72 118 | 73 119 | 74 120 | 75 121 | 76 122 | 77 123 | 78 124 | 79 125 | 80 126 | 81 127 | 82 128 | 83 129 | 84 130 | 85 131 | 86 132 | 87 133 | 88 134 | 89 135 | 90 136 | 91 137 | 92 138 | 93 139 | 94 140 | 95 141 | 96 142 | 97 143 | 98 144 | 99 145 | 100 146 | 101 147 | 102 148 | 103 149 | 104 150 | 105 151 | 106 152 | 107 153 | 108 154 | 109 155 | 110 156 | 111 157 | 112 158 | 113 159 | 114 160 | 115 161 | 116 162 | 117 163 | 118 164 | 119 165 | 120 166 | 121 167 | 122 168 | 123 169 | 124 170 | 125 171 | 126 172 | 127 173 | 128 174 | 129 175 | 130 176 | 131 177 | 132 178 | 133 179 | 134 180 | 135 181 | 136 182 | 137 183 | 138 184 | 139 185 | 140 186 | 141 187 | 142 188 | 143 189 | 144 190 | 145 191 | 146 192 | 147 193 | 148 194 | 149 195 | 150 196 | 151 197 | 152 198 | 153 199 | 154 200 | 155 201 | 156 202 | 157 203 | 158 204 | 159 205 | 160 206 | 161 207 | 162 208 | 163 209 | 164 210 | 165 211 | 166  212 |   213 | 214 | 215 | 216 |   217 | 218 |   219 |   220 |   221 |   222 |   223 |   224 | 225 |   226 |   227 |   228 | 229 |   230 |   231 |   232 |   233 |   234 |   235 | 236 |   237 |   238 |   239 | 240 |   241 |   242 |   243 |   244 | 245 |   246 |   247 |   248 |   249 |   250 |   251 | 252 |   253 |   254 |   255 | 256 |   257 |   258 |   259 |   260 |   261 |   262 | 263 |   264 |   265 |   266 |   267 |   268 |   269 |   270 | 271 |   272 |   273 |   274 |   275 | 276 | 277 | 278 |   279 | 280 |   281 |   282 | 283 | 284 | 285 |   286 | 287 |   288 |   289 | 290 | 291 | 292 |   293 | 294 |   295 |   296 | 297 | 298 | 299 |   300 | 301 |   302 |   303 | 304 | 305 | 306 |   307 | 308 |   309 |   310 | 311 | 312 | 313 |   314 | 315 |   316 |   317 | 318 | 319 | 320 |   321 | 322 |   323 |   324 | 325 | 326 | 327 |   328 | 329 | 330 |   331 | 332 |   333 |   334 | 335 | 336 | 337 |   338 | 339 | 340 |   341 | 342 | 343 |   344 | 345 |   346 |   347 | 348 | 349 | 350 |   351 | 352 | 353 |   354 | 355 |   356 |   357 | 358 | 359 | 360 |   361 | 362 | 363 |   364 | 365 |   366 |   367 | 368 | 369 | 370 |   371 | 372 | 373 |   374 | 375 |   376 |  
'use strict'
377 |  
378 | var test = require('tape')
379 | var _ = require('lodash')
380 | var doiRegex = require('../.')
381 |  
382 | var doi = [
383 |   '10.0001/journal.pone.000001',
384 |   '10.0001/journal/pone.0011111',
385 |   '10.0001.112/journal.pone.0011021',
386 |   '10.0001/issn.10001'
387 | ]
388 |  
389 | var doiOlderFormat = [
390 |   '10.1002/(SICI)1096-8644(199808)106:4<483::AID-AJPA4>3.0.CO;2-K' // one of 300K DOIs from Wiley - see https://www.crossref.org/blog/dois-and-matching-regular-expressions/ for more info
391 | ]
392 |  
393 | var doiNot = [
394 |   '10..1000/journal.pone.0011111',
395 |   '1.1/1.1',
396 |   '10/134980',
397 |   '10.001/001#00'
398 | ]
399 |  
400 | var doiDeclared = [
401 |   'doi:10.1000/journal.pone.0011111',
402 | ]
403 |  
404 | var doiResolvePathWithoutProtocol = [
405 |   'dx.doi.org/10.1016/j.neuron.2014.09.004',
406 |   'doi.org/10.1016/j.neuron.2014.09.004'
407 | ]
408 |  
409 | var doiResolvePathWithProtocol = [
410 |   'http://dx.doi.org/10.1016/j.neuron.2014.09.004',
411 |   'https://dx.doi.org/10.1016/j.neuron.2014.09.004',
412 |   'http://doi.org/10.1016/j.neuron.2014.09.004',
413 |   'https://doi.org/10.1016/j.neuron.2014.09.004'
414 | ]
415 |  
416 | var doiResolvePathInvalid = [
417 |   'dxsdfas.doi.org/10.1016/j.neuron.2014.09.004'
418 | ]
419 |  
420 | var doiResolvePathWithProtocolInvalid = [
421 |   'httpp://dx.doi.org/10.1016/j.neuron.2014.09.004',
422 |   'httpp://doi.org/10.1016/j.neuron.2014.09.004',
423 |   'ftp://dx.doi.org/10.1016/j.neuron.2014.09.004',
424 |   'ftp://doi.org/10.1016/j.neuron.2014.09.004',
425 | ]
426 |  
427 | var doiNotDeclared = [
428 |   'do:10.1000/journal.pone.0011111',
429 |   'doi:10..1000/journal.pone.0011111',
430 |   'DO:10.1000/journal.pone.0011111',
431 |   ':10.1000/journal.pone.0011111',
432 |   '10.1000/journal.pone.0011111'
433 | ]
434 |  
435 | var doiGroups = [
436 |   '10.1000/journal.pone.0011111.a001',
437 |   'doi:10.1000/journal.pone.0011111.a001'
438 | ]
439 |  
440 | test('exact DOIs as passing', function (t) {
441 |   _(doi).each(function (el) {
442 |     t.assert(doiRegex({exact: true}).test(el), el)
443 |   })
444 |   t.end()
445 | })
446 |  
447 | test('older format DOIs as passing', function (t) {
448 |   _(doiOlderFormat).each(function (el) {
449 |     t.assert(doiRegex({exact: true}).test(el), el)
450 |   })
451 |   t.end()
452 | })
453 |  
454 | test('embeded DOIs as passing', function (t) {
455 |   _(doi).each(function (el) {
456 |     t.assert(doiRegex().exec('foo' + el)[0] === el, el)
457 |   })
458 |   t.end()
459 | })
460 |  
461 | test('non-exact DOIs as failing', function (t) {
462 |   _(doiNot).each(function (el) {
463 |     t.assert(!doiRegex({exact: true}).test(el), el)
464 |   })
465 |   t.end()
466 | })
467 |  
468 | test('DOI declared as passing', function (t) {
469 |   _(doiDeclared).each(function (el) {
470 |     t.assert(doiRegex.declared({exact: true}).test(el), el)
471 |   })
472 |   t.end()
473 | })
474 |  
475 | test('DOI declared embeded as passing', function (t) {
476 |   _(doiDeclared).each(function (el) {
477 |     t.assert((doiRegex.declared().exec('foo' + el) || [])[0] === el, el)
478 |   })
479 |   t.end()
480 | })
481 |  
482 | test('DOI not declared as failing', function (t) {
483 |   _(doiNotDeclared).each(function (el) {
484 |     t.assert(!doiRegex.declared({exact: true}).test(el), el)
485 |   })
486 |   t.end()
487 | })
488 |  
489 | test('DOI with resolve path as passing', function (t) {
490 |   _(doiResolvePathWithoutProtocol).each(function (el) {
491 |     t.assert(doiRegex.resolvePath().test(el), el)
492 |   })
493 |   _(doiResolvePathInvalid).each(function (el) {
494 |     t.assert(!doiRegex.resolvePath().test(el), el)
495 |   })
496 |   t.end()
497 | })
498 |  
499 | test('DOI with resolve path and protocol mandatory as passing', function (t) {
500 |   _(doiResolvePathWithoutProtocol).each(function (el) {
501 |     t.assert(!doiRegex.resolvePath({protocol: true}).test(el), el)
502 |   })
503 |   _(doiResolvePathWithProtocol).each(function (el) {
504 |     t.assert(doiRegex.resolvePath({protocol: true}).test(el), el)
505 |   })
506 |   _(doiResolvePathWithProtocolInvalid).each(function (el) {
507 |     t.assert(!doiRegex.resolvePath({protocol: true}).test(el), el)
508 |   })
509 |   t.end()
510 | })
511 |  
512 | test('DOI group catching returns original', function (t) {
513 |   _(doiGroups).each(function (el) {
514 |     t.assert(doiRegex.groups(el)[0] === el, el)
515 |   })
516 |   _(doi).each(function (el) {
517 |     t.assert(doiRegex.groups(el)[0] === el, el)
518 |   })
519 |   t.end()
520 | })
521 |  
522 | test('DOI group catching returns DOI', function (t) {
523 |   _(doiGroups).each(function (el) {
524 |     t.assert(doiRegex(doiRegex.groups(el)[1]), el)
525 |   })
526 |   _(doi).each(function (el) {
527 |     t.assert(doiRegex(doiRegex.groups(el)[1]), el)
528 |   })
529 |   t.end()
530 | })
531 |  
532 | test('DOI group catching returns extension', function (t) {
533 |   _(doiGroups).each(function (el) {
534 |     t.assert(doiRegex.groups(el)[2].length === 5, el)
535 |   })
536 |   _(doi).each(function (el) {
537 |     t.assert(doiRegex.groups(el)[2].length === 0, el)
538 |   })
539 |   t.end()
540 | })
541 |  
543 |
544 |
545 | 549 | 550 | 551 | 558 | 559 | 560 | 561 | -------------------------------------------------------------------------------- /coverage/lcov-report/doi-regex/test.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for doi-regex/test.js 5 | 6 | 7 | 8 | 9 | 196 | 197 | 198 |
199 |

Code coverage report for doi-regex/test.js

200 |

201 | 202 | Statements: 100% (41 / 41)      203 | 204 | 205 | Branches: 50% (1 / 2)      206 | 207 | 208 | Functions: 100% (21 / 21)      209 | 210 | 211 | Lines: 100% (41 / 41)      212 | 213 | Ignored: none      214 |

215 |
All files » doi-regex/ » test.js
216 |
217 |
218 |

219 | 
502 | 
1 220 | 2 221 | 3 222 | 4 223 | 5 224 | 6 225 | 7 226 | 8 227 | 9 228 | 10 229 | 11 230 | 12 231 | 13 232 | 14 233 | 15 234 | 16 235 | 17 236 | 18 237 | 19 238 | 20 239 | 21 240 | 22 241 | 23 242 | 24 243 | 25 244 | 26 245 | 27 246 | 28 247 | 29 248 | 30 249 | 31 250 | 32 251 | 33 252 | 34 253 | 35 254 | 36 255 | 37 256 | 38 257 | 39 258 | 40 259 | 41 260 | 42 261 | 43 262 | 44 263 | 45 264 | 46 265 | 47 266 | 48 267 | 49 268 | 50 269 | 51 270 | 52 271 | 53 272 | 54 273 | 55 274 | 56 275 | 57 276 | 58 277 | 59 278 | 60 279 | 61 280 | 62 281 | 63 282 | 64 283 | 65 284 | 66 285 | 67 286 | 68 287 | 69 288 | 70 289 | 71 290 | 72 291 | 73 292 | 74 293 | 75 294 | 76 295 | 77 296 | 78 297 | 79 298 | 80 299 | 81 300 | 82 301 | 83 302 | 84 303 | 85 304 | 86 305 | 87 306 | 88 307 | 89 308 | 90 309 | 91 310 | 92 311 | 93 312 | 94 313 | 95  314 | 1 315 | 1 316 | 1 317 |   318 | 1 319 |   320 |   321 |   322 | 1 323 |   324 |   325 |   326 |   327 |   328 | 1 329 |   330 |   331 |   332 | 1 333 |   334 |   335 |   336 |   337 |   338 |   339 |   340 | 1 341 |   342 |   343 |   344 |   345 | 1 346 | 1 347 | 1 348 |   349 |   350 |   351 | 1 352 | 1 353 | 1 354 |   355 |   356 |   357 | 1 358 | 1 359 | 3 360 |   361 |   362 |   363 | 1 364 | 1 365 | 1 366 |   367 |   368 |   369 | 1 370 | 1 371 | 1 372 |   373 |   374 |   375 | 1 376 | 1 377 | 5 378 |   379 |   380 |   381 | 1 382 | 1 383 | 2 384 |   385 | 1 386 | 1 387 |   388 |   389 |   390 | 1 391 | 1 392 | 2 393 |   394 | 1 395 | 1 396 |   397 |   398 |   399 | 1 400 | 1 401 | 2 402 |   403 | 1 404 | 1 405 |   406 |   407 |  
'use strict';
408 | var test = require('ava')
409 | var _ = require('lodash')
410 | var doiRegex = require('./');
411 |  
412 | var doi = [
413 | 	'10.1371/journal.pone.0077056'
414 | ];
415 |  
416 | var doiNot = [
417 | 	'10.1000//journal.pone.0011111',
418 | 	'10..1000/journal.pone.0011111',
419 | 	'1.1/1.1'
420 | ];
421 |  
422 | var doiDeclared = [
423 | 	'doi:10.1000/journal.pone.0011111',
424 | ];
425 |  
426 | var doiNotDeclared = [
427 | 	'do:10.1000/journal.pone.0011111',
428 | 	'doi:10..1000/journal.pone.0011111',
429 | 	'DO:10.1000/journal.pone.0011111',
430 | 	':10.1000/journal.pone.0011111',
431 | 	'10.1000/journal.pone.0011111',
432 | ];
433 |  
434 | var doiGroups = [
435 | 	'10.1000/journal.pone.0011111.a001',
436 | 	'doi:10.1000/journal.pone.0011111.a001'
437 | ]
438 |  
439 | test('exact DOIs as passing', function (t) {
440 | 	_(doi).each(function (el) {
441 | 		t.assert(doiRegex({exact: true}).test(el), el)
442 | 	})
443 | })
444 |  
445 | test('embeded DOIs as passing', function (t) {
446 | 	_(doi).each(function (el) {
447 | 		t.assert(doiRegex().exec('foo' + el)[0] === el, el)
448 | 	})
449 | })
450 |  
451 | test('non-exact DOIs as failing', function (t) {
452 | 	_(doiNot).each(function (el) {
453 | 		t.assert(!doiRegex({exact: true}).test(el), el)
454 | 	})
455 | })
456 |  
457 | test('DOI declared as passing', function (t) {
458 | 	_(doiDeclared).each(function (el) {
459 | 		t.assert(doiRegex.declared({exact: true}).test(el), el)
460 | 	})
461 | })
462 |  
463 | test('DOI declared embeded as passing', function (t) {
464 | 	_(doiDeclared).each(function (el) {
465 | 		t.assert((doiRegex.declared().exec('foo' + el) || [])[0] === el, el)
466 | 	})
467 | })
468 |  
469 | test('DOI not declared as failing', function (t) {
470 | 	_(doiNotDeclared).each(function (el) {
471 | 		t.assert(!doiRegex.declared({exact: true}).test(el), el)
472 | 	})
473 | })
474 |  
475 | test('DOI group catching returns original', function (t) {
476 | 	_(doiGroups).each(function (el) {
477 | 		t.assert(doiRegex.groups(el)[0] === el, el)
478 | 	})
479 | 	_(doi).each(function (el) {
480 | 		t.assert(doiRegex.groups(el)[0] === el, el)
481 | 	})
482 | })
483 |  
484 | test('DOI group catching returns DOI', function (t) {
485 | 	_(doiGroups).each(function (el) {
486 | 		t.assert(doiRegex(doiRegex.groups(el)[1]), el)
487 | 	})
488 | 	_(doi).each(function (el) {
489 | 		t.assert(doiRegex(doiRegex.groups(el)[1]), el)
490 | 	})
491 | })
492 |  
493 | test('DOI group catching returns extension', function (t) {
494 | 	_(doiGroups).each(function (el) {
495 | 		t.assert(doiRegex.groups(el)[2].length === 5, el)
496 | 	})
497 | 	_(doi).each(function (el) {
498 | 		t.assert(doiRegex.groups(el)[2].length === 0, el)
499 | 	})
500 | })
501 |  
503 | 504 |
505 | 508 | 509 | 510 | 511 | 512 | 603 | 604 | 605 | --------------------------------------------------------------------------------