Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

fix(plugin-dehydrate): find string in a right way #53

Merged
merged 1 commit into from
Sep 1, 2020

Conversation

oott123
Copy link
Contributor

@oott123 oott123 commented Jul 19, 2020

Summary

Which package does this PR involve? (check one)

  • root project
  • vuepress-plugin-clean-urls
  • vuepress-plugin-container
  • vuepress-plugin-dehydrate
  • vuepress-plugin-medium-zoom
  • vuepress-plugin-named-chunks
  • vuepress-plugin-nprogress
  • vuepress-plugin-redirect
  • vuepress-plugin-smooth-scroll
  • vuepress-plugin-table-of-contents
  • vuepress-plugin-typescript
  • vuepress-plugin-zooming
  • vuepress-mergeable
  • vuepress-types

What kind of change does this PR introduce? (check at least one)

  • Bugfix (fix)
  • Feature (feat)
  • Performance enhancement (perf)
  • Code Style (style)
  • Refactor (refactor)
  • Docs (docs)
  • Build-related changes (build)
  • CI-related changes (ci)
  • Testing (test)
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix #xxx[,#xxx], where "xxx" is the issue number)

Other information:

String.prototype.find will treat the first argument as regexp.

The vairable resourceOriginal, which contents is {{{ renderResourceHints() }}}, was not works as expected because () was treated as regex match groups. This leads to many unused tags generated in the ssr template.

indexOf is safe for any string to find the neddle in string.

`String.prototype.find` will treat the first argument as regexp.

The vairable `resourceOriginal`, which contents is `{{{ renderResourceHints() }}}`, was not works as expected because `()` was treated as regex match groups. This leads to many unused tags generated in the ssr template.

indexOf is safe for any string to find the neddle in string.
@meteorlxy
Copy link
Member

Why do you think current usage is not correct?

@oott123
Copy link
Contributor Author

oott123 commented Aug 26, 2020

@meteorlxy because it wont find renderResourceHints tag correctly and it will add '<!--before-resource-hints-->' and '<!--after-resource-hints-->' tags every time you build the site, no matter they exists or not.

@meteorlxy
Copy link
Member

@oott123 Oh nice catch. Thanks ❤️

cc @shigma

@meteorlxy meteorlxy changed the title fix(dehydrate): find string in a right way fix(plugin-dehydrate): find string in a right way Sep 1, 2020
@meteorlxy meteorlxy merged commit 549c900 into vuepress:master Sep 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants