Skip to content

Commit 01e27e0

Browse files
gkalpakAnkush Agarwal
authored andcommitted
fix(code.angularjs.org): correctly re-construct paths on Windows in sendStoredFile()
Previously, the `sendStoredFile()` Firebase function used `.split('/')` to split the request path into segments and later used `path.join()` to join them back together. This worked fine on *nix based systems, which use `/` as the path separator. On Windows, however, where `\` is the path separator, the re-constructed paths could not be retrieved from the Google Cloud Storage bucket. This prevented the Firebase emulators from working correctly when testing the function locally on Windows. This commit fixes the issue by using `.join('/')` to join the path segments back together. Closes angular#17114
1 parent 824620e commit 01e27e0

File tree

1 file changed

+2
-3
lines changed
  • scripts/code.angularjs.org-firebase/functions

1 file changed

+2
-3
lines changed

scripts/code.angularjs.org-firebase/functions/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
const functions = require('firebase-functions');
44
const {Storage} = require('@google-cloud/storage');
5-
const path = require('path');
65

76
const storage = new Storage();
87
const gcsBucketId = `${process.env.GCLOUD_PROJECT}.appspot.com`;
@@ -41,13 +40,13 @@ function sendStoredFile(request, response) {
4140
return getDirectoryListing('/').catch(sendErrorResponse);
4241
}
4342

44-
downloadSource = path.join.apply(null, filePathSegments);
43+
downloadSource = filePathSegments.join('/');
4544

4645
downloadAndSend(downloadSource).catch(error => {
4746
if (isDocsPath && error.code === 404) {
4847
fileName = 'index.html';
4948
filePathSegments = [version, 'docs', fileName];
50-
downloadSource = path.join.apply(null, filePathSegments);
49+
downloadSource = filePathSegments.join('/');
5150

5251
return downloadAndSend(downloadSource);
5352
}

0 commit comments

Comments
 (0)