vuepress / vuepress-community

:bulb: Community supported ecosystem for VuePress
https://vuepress-community.netlify.app
MIT License
81 stars 62 forks source link

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

Closed oott123 closed 4 years ago

oott123 commented 4 years ago

Summary

Which package does this PR involve? (check one)

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

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

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

The PR fulfills these requirements:

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.

meteorlxy commented 4 years ago

Why do you think current usage is not correct?

oott123 commented 4 years ago

@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 commented 4 years ago

@oott123 Oh nice catch. Thanks :heart:

cc @Shigma