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

perf(external_link): faster regexp #4536

Merged
merged 1 commit into from Sep 17, 2020
Merged

Conversation

SukkaW
Copy link
Member

@SukkaW SukkaW commented Sep 16, 2020

What does it do?

Faster regexp for a little bit performance improvements.

How to test

git clone -b BRANCH https://github.com/USER/hexo.git
cd hexo
npm install
npm test

Screenshots

Pull request tasks

  • Add test cases for the changes.
  • Passed the CI test.

@@ -2,7 +2,7 @@

const { isExternalLink } = require('hexo-util');
let EXTERNAL_LINK_POST_ENABLED = true;
const rATag = /<a(?:\s+?|\s+?[^<>]+\s+?)?href=["']((?:\/\/|http(?:s)?:)[^<>"']+)["'][^<>]*>/gi;
const rATag = /<a(?:\s+?|\s+?[^<>]+\s+?)?href=["']((?:http(?:s)?:|\/\/)[^<>"']+)["'][^<>]*>/gi;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is more common to have https:// and http:// inside links instead of //. By moving \/\/ backward it is a little bit faster.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 98.303% when pulling 75f9f0d on SukkaW:perf-regexp into d445b68 on hexojs:master.

@curbengh curbengh merged commit 41a7239 into hexojs:master Sep 17, 2020
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

Successfully merging this pull request may close these issues.

None yet

3 participants