Skip to content

Commit b3c1064

Browse files
committed
Implement unknownProperty in FastbootHeaders to prevent users from trolling
If a user mistakenly uses `Ember.get(headers, headerName)` it will work now, but will warn the user to use `header.get(headerName)` instead.
1 parent 2825781 commit b3c1064

4 files changed

Lines changed: 15 additions & 14 deletions

File tree

package-lock.json

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"devDependencies": {
3939
"chai": "^4.1.0",
4040
"chai-as-promised": "^7.1.1",
41+
"ember-source": "2.16.2",
4142
"express": "^4.15.4",
4243
"fs-promise": "^2.0.3",
4344
"mocha": "^4.0.0",

src/fastboot-headers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class FastBootHeaders {
9292
}
9393

9494
unknownProperty(maybeHeader) {
95-
console.warn(`You called \`Ember.get(headers, '${maybeHeader}')\` with a FastBootHeaders instance as first argument. FastBootHeader is not an Ember object and you should use \`headers.get('${maybeHeader}')\` instead.`)
95+
console.warn(`You called \`Ember.get(headers, '${maybeHeader}')\` with a FastBootHeaders instance as first argument. FastBootHeader is not an Ember object and you should use \`headers.get('${maybeHeader}')\` instead.`);
9696
return this.get(maybeHeader);
9797
}
9898
}

test/fastboot-headers-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ describe('FastBootHeaders', function() {
148148
expect(entriesIterator.next()).to.deep.equal({ value: undefined, done: true });
149149
});
150150

151-
it('then used with mistakenly `Ember.get` with an unknown property, it attempts to get the header with that name and warns the user to use `headers.get` instead', function () {
151+
it('when mistakenly used `Ember.get` with an unknown property, it attempts to get the header with that name and warns the user to use `headers.get` instead', function () {
152152
var headers = {
153153
'x-test-header': ['value1', 'value2']
154154
};

0 commit comments

Comments
 (0)