Skip to content

Commit

Permalink
Remove relative segments when prepending
Browse files Browse the repository at this point in the history
Consistent with prepending behavior prior to ember-cli#35. Which even removes all depths of relative segments, regardless if it resolves to a valid asset. Perhaps that was never intentional, but nobody's complained.

Fixes ember-cli#36.
  • Loading branch information
john-kurkowski committed Jun 29, 2016
1 parent 1c9ced0 commit e88659a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ AssetRewrite.prototype.rewriteAssetPath = function (string, assetPath, replaceme
replaceString = match[1].replace(assetPath, replacementPath);

if (this.prepend && replaceString.indexOf(this.prepend) !== 0) {
var removeLeadingSlashRegex = new RegExp('^/?(.*)$');
replaceString = this.prepend + removeLeadingSlashRegex.exec(replaceString)[1];
var removeLeadingRelativeOrSlashRegex = new RegExp('^(\\.*/)*(.*)$');
replaceString = this.prepend + removeLeadingRelativeOrSlashRegex.exec(replaceString)[2];
}

newString = newString.replace(new RegExp(escapeRegExp(match[1]), 'g'), replaceString);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.sample-img{width:50px;height:50px;background-image:url('images/foobar.png')}

.sample-img2{width:50px;height:50px;background-image:url('../img/saturation.png')}
.sample-img2{width:50px;height:50px;background-image:url('../../../img/saturation.png')}

0 comments on commit e88659a

Please sign in to comment.