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

Local dependencies in different paths with matching prefixes bug in new dependency lookup #81

Merged
merged 2 commits into from
Sep 26, 2014

Conversation

bowd
Copy link
Contributor

@bowd bowd commented Sep 26, 2014

This bug was introduced by me with the nested components lookup changes #75

The test shows it pretty well but as a recap:

The top-level component has: two paths: lib1 and lib2.

  • lib1 contains the test component.
  • lib2 contains the test_again component.

The top-level component also defines test and test_again as local dependencies.

When the component requires test_again the lookup process finds test as local dependency that matches as a prefix of the require statement, and considers _again as the tail.

This is because we don't enforce the tail to be separate from the main component name by a slash.


By enforcing that slash to be part of the tail in the regexp and also making it optional and default to "" (because now it can't match an empty string anymore because of the slash), we fix this problem and the test passes.

This is noticavle when you have two dependencies that have
the same prefix but that are in different paths.
When looking through the local dependencies of a component we picked the
one that matches a prefix for our require statement, and wanted to
support a tail (that would fetch a specific file in the component). But
we didn't enforce the `/` to be part of the tail so for example if we
had two components: ``test`` and ``test_again`` and they were both local
dependencies ``test_again`` would match as ``test`` and tail ``_again``.
timaschew added a commit that referenced this pull request Sep 26, 2014
Local dependencies in different paths with matching prefixes bug in new dependency lookup
@timaschew timaschew merged commit a4c8a33 into componentjs:master Sep 26, 2014
@timaschew
Copy link
Member

regexps with .* are dangerous sometimes ;)

good catch, thanks!

@timaschew
Copy link
Member

just realized that you need the extension, in component 0.19 it also works without the file extension. So currently it's still a breaking change.

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.

2 participants