Skip to content

Commit d45d2a0

Browse files
committed
[DE-506] Normalize index names
1 parent 83353e8 commit d45d2a0

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ This driver uses semantic versioning:
1414
- A change in the major version (e.g. 1.Y.Z -> 2.0.0) indicates _breaking_
1515
changes that require changes in your code to upgrade.
1616

17+
## [Unreleased]
18+
19+
### Changed
20+
21+
- Index names are now automatically NFC-normalized (DE-506)
22+
23+
This change affects all index names using unicode characters. **The change
24+
has no effect when using non-unicode (ASCII) names.**
25+
26+
Any names used when creating/ensuring indexes or passed to any methods that
27+
expect an `IndexSelector` will automatically be NFC normalized.
28+
1729
## [8.1.0] - 2022-12-19
1830

1931
### Added
@@ -1558,6 +1570,7 @@ For a detailed list of changes between pre-release versions of v7 see the
15581570

15591571
Graph methods now only return the relevant part of the response body.
15601572

1573+
[unreleased]: https://github.com/arangodb/arangojs/compare/v8.1.0...HEAD
15611574
[8.1.0]: https://github.com/arangodb/arangojs/compare/v8.0.0...v8.1.0
15621575
[8.0.0]: https://github.com/arangodb/arangojs/compare/v7.8.0...v8.0.0
15631576
[7.8.0]: https://github.com/arangodb/arangojs/compare/v7.7.0...v7.8.0

src/collection.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4075,6 +4075,10 @@ export class Collection<T extends Record<string, any> = any>
40754075
| EnsureZkdIndexOptions
40764076
| EnsureInvertedIndexOptions
40774077
) {
4078+
const opts = { ...options };
4079+
if (opts.name) {
4080+
opts.name = opts.name.normalize("NFC");
4081+
}
40784082
return this._db.request({
40794083
method: "POST",
40804084
path: "/_api/index",

src/indexes.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,8 @@ export function _indexHandle(
701701
`Index ID "${selector}" does not match collection name "${collectionName}"`
702702
);
703703
}
704-
return [normalizedHead, ...tail].join("/");
704+
selector = tail.join("/").normalize("NFC");
705+
return [normalizedHead, selector].join("/");
705706
}
706-
return `${collectionName}/${selector}`;
707+
return `${collectionName}/${String(selector).normalize("NFC")}`;
707708
}

0 commit comments

Comments
 (0)