MCPcopy Index your code
hub / github.com/TruthHun/BookStack / findPartPath

Function findPartPath

static/word2md/mammoth.browser.js:1654–1673  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

1652}
1653
1654function findPartPath(options) {
1655 var docxFile = options.docxFile;
1656 var relationships = options.relationships;
1657 var relationshipType = options.relationshipType;
1658 var basePath = options.basePath;
1659 var fallbackPath = options.fallbackPath;
1660
1661 var targets = relationships.findTargetsByType(relationshipType);
1662 var normalisedTargets = targets.map(function(target) {
1663 return stripPrefix(zipfile.joinPath(basePath, target), "/");
1664 });
1665 var validTargets = normalisedTargets.filter(function(target) {
1666 return docxFile.exists(target);
1667 });
1668 if (validTargets.length === 0) {
1669 return fallbackPath;
1670 } else {
1671 return validTargets[0];
1672 }
1673}
1674
1675function stripPrefix(value, prefix) {
1676 if (value.substring(0, prefix.length) === prefix) {

Callers 2

findPartPathsFunction · 0.70

Calls 1

stripPrefixFunction · 0.70

Tested by

no test coverage detected