Skip to content

Commit c5abf0e

Browse files
dmellstromsimonua
authored andcommitted
Revert "Add trailing separator to file.base if not present (#165)"
This reverts commit 4149664.
1 parent a284cf7 commit c5abf0e

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

index.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,7 @@ function templateCacheFiles(root, base, templateBody, transformUrl, escapeOption
6262
if (typeof base === 'function') {
6363
url = path.join(root, base(file));
6464
} else {
65-
if (base === undefined) {
66-
// Make sure file.base ends in a separator, to ensure correct relative
67-
// path construction (provides compatibility with Gulp 4/Vinyl 2)
68-
base = file.base += file.base.substr(-1) === path.sep ? "" : path.sep;
69-
}
70-
url = path.join(root, file.path.replace(base, ''));
65+
url = path.join(root, file.path.replace(base || file.base, ''));
7166
}
7267

7368
if (root === '.' || root.indexOf('./') === 0) {

test/test.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('gulp-angular-templatecache', function () {
1212
stream.on('data', function (file) {
1313
assert.equal(path.normalize(file.path), path.normalize(__dirname + '/templates.js'));
1414
assert.equal(file.relative, 'templates.js');
15-
assert.equal(file.contents.toString('utf8'), 'angular.module(\'templates\').run([\'$templateCache\', function($templateCache) {$templateCache.put(\'template-a.html\',\'<h1 id="template-a">I\\\'m template A!</h1>\');\n$templateCache.put(\'template-b.html\',\'<h1 id="template-b">I\\\'m template B!</h1>\');}]);');
15+
assert.equal(file.contents.toString('utf8'), 'angular.module(\'templates\').run([\'$templateCache\', function($templateCache) {$templateCache.put(\'/template-a.html\',\'<h1 id="template-a">I\\\'m template A!</h1>\');\n$templateCache.put(\'/template-b.html\',\'<h1 id="template-b">I\\\'m template B!</h1>\');}]);');
1616
cb();
1717
});
1818

@@ -155,7 +155,7 @@ describe('gulp-angular-templatecache', function () {
155155
stream.on('data', function (file) {
156156
assert.equal(path.normalize(file.path), path.normalize(__dirname + '/templates.js'));
157157
assert.equal(file.relative, 'templates.js');
158-
assert.equal(file.contents.toString('utf8'), 'angular.module(\'templates\').run([\'$templateCache\', function($templateCache) {$templateCache.put(\'tpl-a.html\',\'<h1 id="template-a">I\\\'m template A!</h1>\');}]);');
158+
assert.equal(file.contents.toString('utf8'), 'angular.module(\'templates\').run([\'$templateCache\', function($templateCache) {$templateCache.put(\'/tpl-a.html\',\'<h1 id="template-a">I\\\'m template A!</h1>\');}]);');
159159
cb();
160160
});
161161

@@ -205,7 +205,7 @@ describe('gulp-angular-templatecache', function () {
205205
stream.on('data', function (file) {
206206
assert.equal(path.normalize(file.path), path.normalize(__dirname + '/templates.js'));
207207
assert.equal(file.relative, 'templates.js');
208-
assert.equal(file.contents.toString('utf8'), 'angular.module(\'templates\', []).run([\'$templateCache\', function($templateCache) {$templateCache.put(\'template-a.html\',\'<h1 id="template-a">I\\\'m template A!</h1>\');}]);');
208+
assert.equal(file.contents.toString('utf8'), 'angular.module(\'templates\', []).run([\'$templateCache\', function($templateCache) {$templateCache.put(\'/template-a.html\',\'<h1 id="template-a">I\\\'m template A!</h1>\');}]);');
209209
cb();
210210
});
211211

@@ -331,7 +331,7 @@ describe('gulp-angular-templatecache', function () {
331331
stream.on('data', function (file) {
332332
assert.equal(file.path, path.normalize(__dirname + '/templates.js'));
333333
assert.equal(file.relative, 'templates.js');
334-
assert.equal(file.contents.toString('utf8'), '\'use strict\'; module.exports = angular.module(\'templates\', []).run([\'$templateCache\', function($templateCache) {$templateCache.put(\'template-a.html\',\'<h1 id="template-a">I\\\'m template A!</h1>\');}]);');
334+
assert.equal(file.contents.toString('utf8'), '\'use strict\'; module.exports = angular.module(\'templates\', []).run([\'$templateCache\', function($templateCache) {$templateCache.put(\'/template-a.html\',\'<h1 id="template-a">I\\\'m template A!</h1>\');}]);');
335335
cb();
336336
});
337337

@@ -352,7 +352,7 @@ describe('gulp-angular-templatecache', function () {
352352
stream.on('data', function (file) {
353353
assert.equal(path.normalize(file.path), path.normalize(__dirname + '/templates.js'));
354354
assert.equal(file.relative, 'templates.js');
355-
assert.equal(file.contents.toString('utf8'), 'define([\'angular\'], function(angular) { \'use strict\'; return angular.module(\'templates\').run([\'$templateCache\', function($templateCache) {$templateCache.put(\'template-a.html\',\'<h1 id="template-a">I\\\'m template A!</h1>\');}]);});');
355+
assert.equal(file.contents.toString('utf8'), 'define([\'angular\'], function(angular) { \'use strict\'; return angular.module(\'templates\').run([\'$templateCache\', function($templateCache) {$templateCache.put(\'/template-a.html\',\'<h1 id="template-a">I\\\'m template A!</h1>\');}]);});');
356356
cb();
357357
});
358358

@@ -373,7 +373,7 @@ describe('gulp-angular-templatecache', function () {
373373
stream.on('data', function (file) {
374374
assert.equal(path.normalize(file.path), path.normalize(__dirname + '/templates.js'));
375375
assert.equal(file.relative, 'templates.js');
376-
assert.equal(file.contents.toString('utf8'), 'import angular from \'angular\'; export default angular.module(\'templates\').run([\'$templateCache\', function($templateCache) {$templateCache.put(\'template-a.html\',\'<h1 id="template-a">I\\\'m template A!</h1>\');}]);');
376+
assert.equal(file.contents.toString('utf8'), 'import angular from \'angular\'; export default angular.module(\'templates\').run([\'$templateCache\', function($templateCache) {$templateCache.put(\'/template-a.html\',\'<h1 id="template-a">I\\\'m template A!</h1>\');}]);');
377377
cb();
378378
});
379379

@@ -394,7 +394,7 @@ describe('gulp-angular-templatecache', function () {
394394
stream.on('data', function (file) {
395395
assert.equal(path.normalize(file.path), path.normalize(__dirname + '/templates.js'));
396396
assert.equal(file.relative, 'templates.js');
397-
assert.equal(file.contents.toString('utf8'), '(function(){\'use strict\';angular.module(\'templates\').run([\'$templateCache\', function($templateCache) {$templateCache.put(\'template-a.html\',\'<h1 id="template-a">I\\\'m template A!</h1>\');}]);})();');
397+
assert.equal(file.contents.toString('utf8'), '(function(){\'use strict\';angular.module(\'templates\').run([\'$templateCache\', function($templateCache) {$templateCache.put(\'/template-a.html\',\'<h1 id="template-a">I\\\'m template A!</h1>\');}]);})();');
398398
cb();
399399
});
400400

@@ -420,7 +420,7 @@ describe('gulp-angular-templatecache', function () {
420420
stream.on('data', function (file) {
421421
assert.equal(file.path, path.normalize(__dirname + '/templates.js'));
422422
assert.equal(file.relative, 'templates.js');
423-
assert.equal(file.contents.toString('utf8'), 'var template = "$templateCache.put(\'template-a.html\',\'yoo\');";');
423+
assert.equal(file.contents.toString('utf8'), 'var template = "$templateCache.put(\'/template-a.html\',\'yoo\');";');
424424
cb();
425425
});
426426

@@ -442,7 +442,7 @@ describe('gulp-angular-templatecache', function () {
442442
stream.on('data', function (file) { assert
443443
assert.equal(file.path, path.normalize(__dirname + '/templates.js'));
444444
assert.equal(file.relative, 'templates.js');
445-
assert.equal(file.contents.toString('utf8'), '$templateCache.put(\'template-a.html\',\'yoo\');');
445+
assert.equal(file.contents.toString('utf8'), '$templateCache.put(\'/template-a.html\',\'yoo\');');
446446
cb();
447447
});
448448

@@ -466,7 +466,7 @@ describe('gulp-angular-templatecache', function () {
466466
stream.on('data', function (file) {
467467
assert.equal(file.path, path.normalize(__dirname + '/templates.js'));
468468
assert.equal(file.relative, 'templates.js');
469-
assert.equal(file.contents.toString('utf8'), 'angular.module(\'templates\').run([\'$templateCache\', function($templateCache) {$templateCache.put(\'template-a.html\',\'yoo\');}]);');
469+
assert.equal(file.contents.toString('utf8'), 'angular.module(\'templates\').run([\'$templateCache\', function($templateCache) {$templateCache.put(\'/template-a.html\',\'yoo\');}]);');
470470
cb();
471471
});
472472

0 commit comments

Comments
 (0)