-
Notifications
You must be signed in to change notification settings - Fork 151
Open
Description
In src/index.js
substituteHyperlinks(rels, substitutions) {
...
const relationships = rels.root._children;
...
}
In lib/index.ts
protected substituteHyperlinks(sheetFilename : any, substitutions : any) : void;
Definition in v1.0.0
Workbook.prototype.substituteHyperlinks = function(sheetFilename, substitutions) {
let self = this;
const sheetDirectory = path.dirname(sheetFilename),
sheetName = path.basename(sheetFilename),
relsFilename = sheetDirectory + "/" + '_rels' + "/" + sheetName + '.rels',
relsFile = self.archive.file(relsFilename);
etree.parse(self.archive.file(self.sharedStringsPath).asText()).getroot();
if(relsFile === null) {
return;
}
const rels = etree.parse(relsFile.asText()).getroot();
const relationships = rels._children;
const newRelationships = [];
relationships.forEach(function(relationship){
newRelationships.push(relationship);
if(relationship.attrib.Type === HYPERLINK_RELATIONSHIP) {
let target = relationship.attrib.Target;
//Double-decode due to excel double encoding url placeholders
target = decodeURI(decodeURI(target));
self.extractPlaceholders(target).forEach(function (placeholder) {
const substitution = substitutions[placeholder.name];
if (substitution === undefined) {
return;
}
target = target.replace(placeholder.placeholder, self.stringify(substitution));
relationship.attrib.Target = encodeURI(target);
}
);
}
});
self.replaceChildren(rels, newRelationships);
self.archive.file(relsFilename, etree.tostring(rels));
};Definition in v1.4.4
substituteHyperlinks(rels, substitutions) {
let self = this;
etree.parse(self.archive.file(self.sharedStringsPath).asText()).getroot();
if (rels === null) {
return;
}
const relationships = rels.root._children;
relationships.forEach(function (relationship) {
if (relationship.attrib.Type === HYPERLINK_RELATIONSHIP) {
let target = relationship.attrib.Target;
//Double-decode due to excel double encoding url placeholders
target = decodeURI(decodeURI(target));
self.extractPlaceholders(target).forEach(function (placeholder) {
const substitution = substitutions[placeholder.name];
if (substitution === undefined) {
return;
}
target = target.replace(placeholder.placeholder, self.stringify(substitution));
relationship.attrib.Target = encodeURI(target);
}
);
}
});
}Trying to migrate from v1.0.0 to v1.4.4
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels