Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

chore(*): fix serving of URI-encoded files on code.angularjs.org #16943

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ performance/temp*.html
angular.js.tmproj
node_modules/
angular.xcodeproj
.firebase/
.idea
*.iml
.agignore
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@
"dependencies": {},
"resolutions": {
"//1": "`[email protected]` does not work with Node.js 10.x on Windows 10",
"//2": "(E.g. see https://github.com/gulpjs/gulp/issues/2162.)",
"natives": "1.1.3"
"//2": "(E.g. see https://github.com/gulpjs/gulp/issues/2162 and https://github.com/nodejs/node/issues/25132.)",
"natives": "1.1.6"
},
"commitplease": {
"style": "angular",
Expand Down
6 changes: 5 additions & 1 deletion scripts/code.angularjs.org-firebase/functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ const BROWSER_CACHE_DURATION = 60 * 10;
const CDN_CACHE_DURATION = 60 * 60 * 12;

function sendStoredFile(request, response) {
const requestPath = request.path || '/';
// Request paths will be URI-encoded, so we need to decode them to match the file names in the
// storage bucket. Failing to do so will result in a 404 error from the bucket and `index.html`
// will be returned instead.
// Example of path requiring decoding: `.../input%5Btext%5D.html` --> `.../input[text].html`
const requestPath = decodeURI(request.path || '/');
let filePathSegments = requestPath.split('/').filter((segment) => {
// Remove empty leading or trailing path parts
return segment !== '';
Expand Down
3 changes: 3 additions & 0 deletions scripts/code.angularjs.org-firebase/functions/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "functions-firebase-code.angularjs.org",
"description": "Cloud Functions to serve files from gcs to code.angularjs.org",
"engines": {
"node": "8"
},
"dependencies": {
"@google-cloud/storage": "^1.1.1",
"firebase-admin": "^5.11.0",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5440,10 +5440,10 @@ nanomatch@^1.2.9:
snapdragon "^0.8.1"
to-regex "^3.0.1"

[email protected].3, natives@^1.1.0:
version "1.1.3"
resolved "https://registry.yarnpkg.com/natives/-/natives-1.1.3.tgz#44a579be64507ea2d6ed1ca04a9415915cf75558"
integrity sha512-BZGSYV4YOLxzoTK73l0/s/0sH9l8SHs2ocReMH1f8JYSh5FUWu4ZrKCpJdRkWXV6HFR/pZDz7bwWOVAY07q77g==
[email protected].6, natives@^1.1.0:
version "1.1.6"
resolved "https://registry.yarnpkg.com/natives/-/natives-1.1.6.tgz#a603b4a498ab77173612b9ea1acdec4d980f00bb"
integrity sha512-6+TDFewD4yxY14ptjKaS63GVdtKiES1pTPyxn9Jb0rBqPMZ7VcCiooEhPNsr+mqHtMGxa/5c/HhcC4uPEUw/nA==

natural-compare@^1.4.0:
version "1.4.0"
Expand Down