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

Commit a6fa9cc

Browse files
committed
fix($resource) add @ support for properties names
Add support for properties that starts with @. This is useful when working with BadgerFish convention.
1 parent 171b9f7 commit a6fa9cc

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/ngResource/resource.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var $resourceMinErr = angular.$$minErr('$resource');
55
// Helper functions and regex to lookup a dotted path on an object
66
// stopping at undefined/null. The path must be composed of ASCII
77
// identifiers (just like $parse)
8-
var MEMBER_NAME_REGEX = /^(\.[a-zA-Z_$][0-9a-zA-Z_$]*)+$/;
8+
var MEMBER_NAME_REGEX = /^(\.[a-zA-Z_$@][0-9a-zA-Z_$]*)+$/;
99

1010
function isValidDottedPath(path) {
1111
return (path != null && path !== '' && path !== 'hasOwnProperty' &&

test/ngResource/resourceSpec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ describe("resource", function() {
4444
expect(isValidDottedPath('1abc')).toBe(false);
4545
expect(isValidDottedPath('.')).toBe(false);
4646
expect(isValidDottedPath('$')).toBe(true);
47+
expect(isValidDottedPath('@')).toBe(true);
4748
expect(isValidDottedPath('a')).toBe(true);
4849
expect(isValidDottedPath('A')).toBe(true);
4950
expect(isValidDottedPath('a1')).toBe(true);
@@ -53,6 +54,8 @@ describe("resource", function() {
5354
expect(isValidDottedPath('$.$')).toBe(true);
5455
expect(isValidDottedPath('.$')).toBe(false);
5556
expect(isValidDottedPath('$.')).toBe(false);
57+
expect(isValidDottedPath('@.')).toBe(false);
58+
expect(isValidDottedPath('.@')).toBe(false);
5659
});
5760
});
5861

0 commit comments

Comments
 (0)