Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid regular expression: /[~]string)$/: Unmatched ')' #417

Open
2 of 5 tasks
jrop opened this issue Apr 25, 2017 · 1 comment
Open
2 of 5 tasks

Invalid regular expression: /[~]string)$/: Unmatched ')' #417

jrop opened this issue Apr 25, 2017 · 1 comment

Comments

@jrop
Copy link

jrop commented Apr 25, 2017

Make sure these boxes are checked before submitting your issue - thank you!
(If your issue is neither a both bug nor a request, please write in a free style)

Short summary of your issue

The following code causes ESDoc to error:

/**
 * ...function description...
 * @param {(number|string)[]} param ...param description...
 */
parse(...rbpsOrTypes: (number|string)[]): any {
    // ...
}

If I change to @param {number[]|string[]} param ..., then it works.

Input data for reproducing

Configuration

{
  "source": "lib/",
  "destination": "gh-pages/"
}

Codes

(see above)

Output data

Log

parse: ./lib/index.js
parse: ./lib/test.js
resolve: extends chain
resolve: necessary
resolve: access
resolve: unexported identifier
resolve: undocument identifier
resolve: duplication
resolve: ignore
resolve: link
resolve: markdown in description
resolve: test relation
output: badge.svg
output: identifiers.html
output: index.html

SyntaxError: Invalid regular expression: /[~]string)$/: Unmatched ')'
    at new RegExp (<anonymous>)
    at ClassDocBuilder._findByName (./node_modules/esdoc/out/src/Publisher/Builder/DocBuilder.js:114:20)
    at ClassDocBuilder._buildDocLinkHTML (./node_modules/esdoc/out/src/Publisher/Builder/DocBuilder.js:845:22)
    at ClassDocBuilder._buildTypeDocLinkHTML (./node_modules/esdoc/out/src/Publisher/Builder/DocBuilder.js:735:29)
    at ClassDocBuilder._buildSignatureHTML (./node_modules/esdoc/out/src/Publisher/Builder/DocBuilder.js:912:27)
    at ice.loop (./node_modules/esdoc/out/src/Publisher/Builder/DocBuilder.js:410:34)
    at IceCap.loop (./node_modules/ice-cap/out/src/IceCap.js:261:9)
    at ClassDocBuilder._buildSummaryDoc (./node_modules/esdoc/out/src/Publisher/Builder/DocBuilder.js:406:9)
    at ClassDocBuilder._buildSummaryHTML (./node_modules/esdoc/out/src/Publisher/Builder/DocBuilder.js:383:27)
    at ClassDocBuilder._buildClassDoc (./node_modules/esdoc/out/src/Publisher/Builder/ClassDocBuilder.js:119:36)

Screen shot of documentation

N/A

Exception output (if possible)

Log

(see above)

Screen shot of documentation

N/A

Your environment

  • OS type and version: macOS
  • Node.js version: v7.7.3
  • ESDoc version: 0.5.2
@larsno
Copy link

larsno commented Nov 21, 2019

The problem is that there is a regular expression created in the function _findByName() on line 116 of node_modules/esdoc-publish-html-plugin/out/src/Builder/DocBuilder.js. This regular expression if created by escaping * in the text. However, your type includes brackets and the regular expression ends up having unbalanced unescaped brackets.

I fixed it by replacing the existing

const regexp = new RegExp(`[~]${name.replace("*", '\\*')}$`); // if name is `*`, need to escape.

with a more comprehensive escaping of the regular expression characters

const regexp = new RegExp(`[~]${name.replace(/([*.()[\]|])/g, '\\$1')}$`); // if name is `*`, need to escape.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants