diff --git a/protocol-tag-utils/index.js b/protocol-tag-utils/index.js index a5a2ff190..deed46070 100644 --- a/protocol-tag-utils/index.js +++ b/protocol-tag-utils/index.js @@ -167,12 +167,8 @@ export const removeAll = (protocol, tags) => update(protocol, [], tags) */ export const removeAllByName = (protocol, name, tags) => { const [start, end] = findProtocolBoundaries(protocol)(tags) - - let [before, cur, after] = [tags.slice(0, start), tags.slice(start, end), tags.slice(end)] - - cur = cur.filter(complement(byName(name))) - - return [before, cur, after].flat(1) + const [before, cur, after] = [tags.slice(0, start), tags.slice(start, end), tags.slice(end)] + return [before, create(protocol, cur.filter(complement(byName(name)))), after].flat(1) } /** diff --git a/protocol-tag-utils/index.test.js b/protocol-tag-utils/index.test.js index 547e1a77f..3cbc7739b 100644 --- a/protocol-tag-utils/index.test.js +++ b/protocol-tag-utils/index.test.js @@ -193,6 +193,17 @@ describe('suite', () => { ) }) + test('should remove protocol, if all tags are removed', () => { + assert.deepStrictEqual( + removeAllByName( + AO, + 'Variant', + removeAllByName(AO, 'Type', TAGS) + ), + [RAND, ZONE_TAGS].flat(1) + ) + }) + test('should do nothing', () => { assert.deepStrictEqual(removeAllByName(AO, 'Foo', TAGS), TAGS) assert.deepStrictEqual(removeAllByName(AO, 'Random', TAGS), TAGS)