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 for #560 leading slash added to files in manifest #589

Merged
merged 9 commits into from
Jun 12, 2017
3 changes: 0 additions & 3 deletions packages/workbox-build/src/lib/utils/filter-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ module.exports = (fileDetails, options) => {
// Convert to manifest format
return filteredFileDetails.map((fileDetails) => {
let url = fileDetails.file.replace(path.sep, '/');
if (!url.startsWith('/')) {
url = '/' + url;
}

// Modify URL Prefix
if (options && options.modifyUrlPrefix) {
Expand Down
70 changes: 35 additions & 35 deletions packages/workbox-build/test/node/get-file-manifest-entries.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ describe('Test getFileManifestEntries', function() {
return entry.url;
});
allUrls.should.deep.equal([
'/index.html',
'/page-1.html',
'/page-2.html',
'/styles/stylesheet-1.css',
'/styles/stylesheet-2.css',
'/webpackEntry.js',
'index.html',
'page-1.html',
'page-2.html',
'styles/stylesheet-1.css',
'styles/stylesheet-2.css',
'webpackEntry.js',
]);
});
});
Expand All @@ -118,8 +118,8 @@ describe('Test getFileManifestEntries', function() {
globDirectory: path.join(__dirname, '..', '..', '..',
'workbox-cli', 'test', 'static', 'example-project-1'),
modifyUrlPrefix: {
'/styles': '/static/styles',
'/page': '/pages/page',
'styles': 'static/styles',
'page': 'pages/page',
},
};

Expand All @@ -129,12 +129,12 @@ describe('Test getFileManifestEntries', function() {
return entry.url;
});
allUrls.should.deep.equal([
'/index.html',
'/pages/page-1.html',
'/pages/page-2.html',
'/static/styles/stylesheet-1.css',
'/static/styles/stylesheet-2.css',
'/webpackEntry.js',
'index.html',
'pages/page-1.html',
'pages/page-2.html',
'static/styles/stylesheet-1.css',
'static/styles/stylesheet-2.css',
'webpackEntry.js',
]);
});
});
Expand All @@ -155,11 +155,11 @@ describe('Test getFileManifestEntries', function() {
return entry.url;
});
allUrls.should.deep.equal([
'/page-1.html',
'/page-2.html',
'/styles/stylesheet-1.css',
'/styles/stylesheet-2.css',
'/webpackEntry.js',
'page-1.html',
'page-2.html',
'styles/stylesheet-1.css',
'styles/stylesheet-2.css',
'webpackEntry.js',
]);
});
});
Expand Down Expand Up @@ -199,7 +199,7 @@ describe('Test getFileManifestEntries', function() {
'workbox-cli', 'test', 'static', 'example-project-1'),
templatedUrls: {
'/template/url1': ['page-1.html', 'index.html'],
'/template/url2': ['page-2.html', 'index.html'],
'template/url2': ['page-2.html', 'index.html'],
'/template/url3': '<html><head></head><body><p>Just in case</p></body></html>',
},
};
Expand All @@ -210,14 +210,14 @@ describe('Test getFileManifestEntries', function() {
return entry.url;
});
allUrls.should.deep.equal([
'/index.html',
'/page-1.html',
'/page-2.html',
'/styles/stylesheet-1.css',
'/styles/stylesheet-2.css',
'/webpackEntry.js',
'index.html',
'page-1.html',
'page-2.html',
'styles/stylesheet-1.css',
'styles/stylesheet-2.css',
'webpackEntry.js',
'/template/url1',
'/template/url2',
'template/url2',
'/template/url3',
]);
});
Expand All @@ -232,7 +232,7 @@ describe('Test getFileManifestEntries', function() {
'workbox-cli', 'test', 'static', 'example-project-1'),
dynamicUrlToDependencies: {
'/template/url1': ['page-1.html', 'index.html'],
'/template/url2': ['page-2.html', 'index.html'],
'template/url2': ['page-2.html', 'index.html'],
'/template/url3': '<html><head></head><body><p>Just in case</p></body></html>',
},
};
Expand All @@ -250,7 +250,7 @@ describe('Test getFileManifestEntries', function() {
'/styles/stylesheet-2.css',
'/webpackEntry.js',
'/template/url1',
'/template/url2',
'template/url2',
'/template/url3',
]);
});
Expand All @@ -269,12 +269,12 @@ describe('Test getFileManifestEntries', function() {
return swBuild.getFileManifestEntries(testInput)
.then((output) => {
output.should.deep.equal([
'/index.html',
'/page-1.html',
'/page-2.html',
'/styles/stylesheet-1.css',
'/styles/stylesheet-2.css',
'/webpackEntry.js',
'index.html',
'page-1.html',
'page-2.html',
'styles/stylesheet-1.css',
'styles/stylesheet-2.css',
'webpackEntry.js',
]);
});
});
Expand Down
4 changes: 2 additions & 2 deletions packages/workbox-build/test/node/injection-manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ describe('Test Injection Manifest', function() {
];
const expectedString = `workboxSW.precache([
{
"url": "/index.css",
"url": "index.css",
"revision": "d41d8cd98f00b204e9800998ecf8427e"
},
{
"url": "/index.html",
"url": "index.html",
"revision": "d41d8cd98f00b204e9800998ecf8427e"
}
])`;
Expand Down
12 changes: 6 additions & 6 deletions packages/workbox-cli/test/node/inject-manifest-e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,27 +75,27 @@ describe('Generate SW End-to-End Tests', function() {
const fileOutput = fs.readFileSync(swDest).toString();
const regex = new RegExp(`someVariables.precache\\(\\[
{
"url": "/images/web-fundamentals-icon192x192.png",
"url": "images/web-fundamentals-icon192x192.png",
"revision": "\\w*"
},
{
"url": "/index.html",
"url": "index.html",
"revision": "\\w*"
},
{
"url": "/page-1.html",
"url": "page-1.html",
"revision": "\\w*"
},
{
"url": "/page-2.html",
"url": "page-2.html",
"revision": "\\w*"
},
{
"url": "/styles/stylesheet-1.css",
"url": "styles/stylesheet-1.css",
"revision": "\\w*"
},
{
"url": "/styles/stylesheet-2.css",
"url": "styles/stylesheet-2.css",
"revision": "\\w*"
}
\\]\\);`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const validateFiles = (fileManifestOutput, exampleProject, fileExtensions, swDes
});

expectedFiles = expectedFiles.map((file) => {
return `/${path.relative(exampleProject, file).replace(path.sep, '/')}`;
return `${path.relative(exampleProject, file).replace(path.sep, '/')}`;
});

if (fileManifestOutput.length !== expectedFiles.length) {
Expand Down