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

fix: index file judgement bug (#306) #308

Merged
merged 1 commit into from
May 1, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ async function genComponentRegistrationFile ({ sourceDir }) {
return `import Vue from 'vue'\n` + components.map(genImport).join('\n')
}

const indexRE = /\b(index|readme)\.md$/i
const indexRE = /(?<=(^|\/))(index|readme)\.md$/i
const extRE = /\.(vue|md)$/
Copy link
Member

Choose a reason for hiding this comment

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

lookbehind is good, how about /(^|\/)(index|readme)\.md$/i? it's same for this case.

Copy link
Member Author

@meteorlxy meteorlxy Apr 30, 2018

Choose a reason for hiding this comment

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

It's not the same. \b will not include the word boundary itself. But /(^|\/)(index|readme)\.md$/i will include the begining /

Copy link
Member

Choose a reason for hiding this comment

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

I meant /(^|\/)(index|readme)\.md$/i ...

Copy link
Member Author

@meteorlxy meteorlxy May 1, 2018

Choose a reason for hiding this comment

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

I meant /(^|\/)(index|readme)\.md$/i too... /(^|\/)(index|readme)\.md$/i has different behavior

Copy link
Member Author

@meteorlxy meteorlxy May 1, 2018

Choose a reason for hiding this comment

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

Well, in other words, \b and (?<=(^|\/)) won't include the begining /, but (^|\/) will.

For instance:

If the path is 'config/README.md':

  • /\b(index|readme)\.md$/i => 'README.md'
  • /(?<=(^|\/))(index|readme)\.md$/i => 'README.md'
  • /(^|\/)(index|readme)\.md$/i => '/README.md'

Copy link
Member

@ulivz ulivz May 1, 2018

Choose a reason for hiding this comment

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

Well, thanks for the explanation. I thought that the indexRE is only used to test, after double confirm, I find it's also used to replace so this is not the same. cool!


function fileToPath (file) {
Expand Down