Skip to content

Commit 855ec02

Browse files
committedMar 24, 2021
Fix #704
1 parent bd2bc20 commit 855ec02

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed
 

‎CHANGELOG.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This driver uses semantic versioning:
1818

1919
### Added
2020

21-
- Implemented `toJSON` methods for `ArangoError` and `HttpError`
21+
- Implemented `toJSON` methods for `ArangoError` and `HttpError` ([#632](https://github.com/arangodb/arangojs/issues/632))
2222

2323
This prevents an error where `JSON.stringify` would reliably throw if passed
2424
an instance of either of these error types generated by arangojs. Note that
@@ -27,7 +27,7 @@ This driver uses semantic versioning:
2727

2828
### Fixed
2929

30-
- Stack traces are now improved for most errors when using `precaptureStackTraces`
30+
- Stack traces are now improved for most errors when using `precaptureStackTraces` ([#722](https://github.com/arangodb/arangojs/issues/722))
3131

3232
Previously this option would only affect network errors, making it far less
3333
useful than intended. Now parsing errors, `ArangoError` instances and HTTP
@@ -40,6 +40,12 @@ This driver uses semantic versioning:
4040
be accessed prior to the request being sent, causing a noticeable delay even
4141
when no error occurs.
4242

43+
- Fixed document selector validation in `collection.edges` and its variants ([#704](https://github.com/arangodb/arangojs/issues/704))
44+
45+
These methods previously only permitted start vertices that are documents
46+
within the edge collection itself. This behavior has now been corrected to
47+
permit start vertices outside the collection, as expected.
48+
4349
## [7.3.0] - 2021-03-08
4450

4551
### Changed

‎src/collection.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3629,7 +3629,7 @@ export class Collection<T extends object = any>
36293629
path: `/_api/edges/${this._name}`,
36303630
qs: {
36313631
direction,
3632-
vertex: _documentHandle(selector, this._name),
3632+
vertex: _documentHandle(selector, this._name, false),
36333633
},
36343634
},
36353635
(res) => res.body

‎src/documents.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ export type DocumentSelector = ObjectWithId | ObjectWithKey | string;
112112
*/
113113
export function _documentHandle(
114114
selector: DocumentSelector,
115-
collectionName: string
115+
collectionName: string,
116+
strict: boolean = true
116117
): string {
117118
if (typeof selector !== "string") {
118119
if (selector._id) {
@@ -126,7 +127,7 @@ export function _documentHandle(
126127
);
127128
}
128129
if (selector.includes("/")) {
129-
if (!selector.startsWith(`${collectionName}/`)) {
130+
if (strict && !selector.startsWith(`${collectionName}/`)) {
130131
throw new Error(
131132
`Document ID "${selector}" does not match collection name "${collectionName}"`
132133
);

0 commit comments

Comments
 (0)