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: unexpected file request with custom publicDir, fix #4629 #4631

Merged
merged 1 commit into from Aug 25, 2021
Merged

fix: unexpected file request with custom publicDir, fix #4629 #4631

merged 1 commit into from Aug 25, 2021

Conversation

hyf0
Copy link
Contributor

@hyf0 hyf0 commented Aug 16, 2021

Description

Fix #4629.

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@hyf0 hyf0 marked this pull request as ready for review August 16, 2021 15:03
@hyf0 hyf0 changed the title fix: only warn when matched configured vite.config.js#publicDir. fix(#4629) fix: should correctly warn about unexpected request of file in vite.config.js#publicDir. fix(#4629) Aug 21, 2021
Copy link
Member

@Shinigami92 Shinigami92 left a comment

Choose a reason for hiding this comment

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

I mean... tests are green, yolo

@patak-dev patak-dev changed the title fix: should correctly warn about unexpected request of file in vite.config.js#publicDir. fix(#4629) fix: unexpected file request with custom publicDir, fix #4629 Aug 25, 2021
@patak-dev patak-dev merged commit 7be6c0c into vitejs:main Aug 25, 2021
Comment on lines +128 to +131
const publicPath =
normalizePath(server.config.publicDir).slice(
server.config.root.length
) + '/'
Copy link
Contributor

Choose a reason for hiding this comment

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

const publicDir = '/foo/public'
const root = '/foo/bar/root'

publicDir.slice(root.length) + '/'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@meteorlxy I guess if root.length is bigger than publicDir.length, we shouldn't throw a warning and just skip it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@meteorlxy Would you like to give a fix? Or I will fix it after home.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it should not be simply determined by the length. It's better to check if publicDir is inside root or not.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just submit a PR to fix that #4927

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.

Public dir warning does not match the configured public dir
4 participants