MCPcopy
hub / github.com/Kong/insomnia / normalizePattern

Function normalizePattern

packages/insomnia/bin/yarn-standalone.js:7597–7628  ·  view source on GitHub ↗

* Explode and normalize a pattern into its name and range.

(pattern)

Source from the content-addressed store, hash-verified

7595 */
7596
7597function normalizePattern(pattern) {
7598 let hasVersion = false;
7599 let range = 'latest';
7600 let name = pattern;
7601
7602 // if we're a scope then remove the @ and add it back later
7603 let isScoped = false;
7604 if (name[0] === '@') {
7605 isScoped = true;
7606 name = name.slice(1);
7607 }
7608
7609 // take first part as the name
7610 const parts = name.split('@');
7611 if (parts.length > 1) {
7612 name = parts.shift();
7613 range = parts.join('@');
7614
7615 if (range) {
7616 hasVersion = true;
7617 } else {
7618 range = '*';
7619 }
7620 }
7621
7622 // add back @ scope suffix
7623 if (isScoped) {
7624 name = `@${name}`;
7625 }
7626
7627 return { name, range, hasVersion };
7628}
7629
7630/***/ }),
7631/* 37 */

Callers

nothing calls this directly

Calls 1

shiftMethod · 0.80

Tested by

no test coverage detected