ember-cli / broccoli-asset-rewrite

Broccoli plugin to rewrite a source tree from an asset map.
MIT License
10 stars 53 forks source link

AssetRewrite.rewriteAssetPath incorrectly matching remote file paths containing the same name as a valid rewrite #24

Open trabus opened 9 years ago

trabus commented 9 years ago

As described in this S.O. issue, if there is a remote file path that contains the same filename as another file that is a valid rewrite (an actual asset path that should be rewritten), the rewriteAssetPath method is processing those paths even though they're to a remote path.

For instance, in a project named coolapp:

model: function() {
  // this path is being rewritten because it's matching `coolapp` but not taking into account that it's from a remote path
  return Ember.$.getJSON('http://my.remote.url.com/coolapp.json');
}

I imagine this probably just needs some adjustments to the regex to prevent matching remote paths.

rickharrison commented 9 years ago

This is unfortunately a pretty complex problem to solve. Any help with failing test cases, etc. would be much appreciated.

trabus commented 9 years ago

I'll try to throw together a test case, and maybe even take a crack at it later tonight. I'm doing something similar with ember-cli-mv, but I'm walking the AST for each file and updating paths there (currently just doing a regex as well).

mcfiredrill commented 9 years ago

@trabus thanks for reporting this!