Skip to content

Commit b9f926b

Browse files
committed
Removed maxDepth. Let server run the validation
1 parent 4cbf0cd commit b9f926b

File tree

4 files changed

+5
-20
lines changed

4 files changed

+5
-20
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/format/IdGenerator.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,20 @@ export class IdGenerator {
3535
/**
3636
* Parses a unified namespace name into a path.
3737
* @param {string} name The unified namespace name.
38-
* @param {number} maxDepth The max namespace depth (network configuration, default: 3)
3938
* @returns {array<module:coders/uint64~uint64>} The namespace path.
4039
*/
41-
public static generateNamespacePath = (name: string, maxDepth: number = idGeneratorConst.default_namespace_max_depth) => {
40+
public static generateNamespacePath = (name: string) => {
4241
if (0 >= name.length) {
4342
utilities.throwInvalidFqn('having zero length', name);
4443
}
4544
let namespaceId = utilities.idGeneratorConst.namespace_base_id;
4645
const path = [];
4746
const start = utilities.split(name, (substringStart, size) => {
4847
namespaceId = utilities.generateNamespaceId(namespaceId, utilities.extractPartName(name, substringStart, size));
49-
utilities.append(path, namespaceId, name, maxDepth);
48+
utilities.append(path, namespaceId, name);
5049
});
5150
namespaceId = utilities.generateNamespaceId(namespaceId, utilities.extractPartName(name, start, name.length - start));
52-
utilities.append(path, namespaceId, name, maxDepth);
51+
utilities.append(path, namespaceId, name);
5352
return path;
5453
}
5554
}

src/core/format/Utilities.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ export const tryParseUint = (str) => {
9494

9595
export const idGeneratorConst = {
9696
namespace_base_id: [0, 0],
97-
default_namespace_max_depth: 3,
9897
name_pattern: /^[a-z0-9][a-z0-9-_]*$/,
9998
};
10099

@@ -113,10 +112,7 @@ export const extractPartName = (name, start, size) => {
113112
return partName;
114113
};
115114

116-
export const append = (path, id, name, maxDepth) => {
117-
if (maxDepth === path.length) {
118-
this.throwInvalidFqn('too many parts', name);
119-
}
115+
export const append = (path, id, name) => {
120116
path.push(id);
121117
};
122118

test/core/format/IdGenerator.spec.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -234,21 +234,11 @@ describe('id generator', () => {
234234
expect(idGenerator.generateNamespacePath('foo.bar.baz')).to.deep.equal(expected);
235235
});
236236

237-
it('rejects names with too many parts', () => {
238-
// Assert:
239-
['a.b.c.d', 'a.b.c.d.e'].forEach((name) =>
240-
expect(() => idGenerator.generateNamespacePath(name), `name ${name}`).to.throw('too many parts'));
241-
});
242-
243237
it('rejects improper qualified names', () => {
244238
// Assert:
245239
['a:b:c', 'a::b'].forEach((name) =>
246240
expect(() => idGenerator.generateNamespacePath(name), `name ${name}`).to.throw('invalid part name'));
247241
});
248-
249-
it('rejects names depth exceeds maxDepth', () => {
250-
expect(() => idGenerator.generateNamespacePath('nem.xem', 1)).to.throw(Error, 'too many parts');
251-
});
252242
addBasicTests(idGenerator.generateNamespacePath);
253243
});
254244
});

0 commit comments

Comments
 (0)