pathchain 1.1.6 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/maker.js +15 -16
  2. package/package.json +1 -1
package/maker.js CHANGED
@@ -234,7 +234,7 @@ function path(text, elements, author, ancestor, format = 'MM DD YYYY HH:mm:SSS [
234
234
  const current_link = link(elements[i], "", "", author, "");
235
235
  if (i > 0) {
236
236
  updater.setLinkNext(prev_link, current_link);
237
- updater.setPrevLink(current_link, prev_link);
237
+ updater.setLinkPrev(current_link, prev_link);
238
238
  }
239
239
  prev_link = current_link;
240
240
  }
@@ -311,11 +311,23 @@ function label(text, author, ancestor, format = 'MM DD YYYY HH:mm:SSS [GMT]Z') {
311
311
  function link(target, prev, next, author, ancestor, format = 'MM DD YYYY HH:mm:SSS [GMT]Z') {
312
312
  // Load the link protocol buffer definition
313
313
  const link_pb = pb(fs.readFileSync('node_modules/pathchain/proto/link.proto'));
314
+ var target_type = "";
314
315
 
315
316
  // Validate target
316
317
  if (target === "") {
317
318
  return "The link must be linking something. The target cannot be null.";
318
319
  }
320
+ else{
321
+ var splitted_target = target.split("/");
322
+ console.log("Splitted target: ", splitted_target);
323
+ target_type = splitted_target[splitted_target.length - 2];
324
+ console.log("Target type: ", target_type);
325
+ }
326
+
327
+ // Homogenize the author.
328
+ // Break down the target address
329
+ // Make a copy of it inside *author* address if it is not public or if the original author is different than *author*
330
+ // What the fuck
319
331
 
320
332
  // Handle author and author folder
321
333
  let author_folder = author;
@@ -338,21 +350,8 @@ function link(target, prev, next, author, ancestor, format = 'MM DD YYYY HH:mm:S
338
350
  if (prev === "") { prev = link_hash; }
339
351
  if (next === "") { next = link_hash; }
340
352
 
341
- // Determine the nature of the target (node, path, or label)
342
- let target_type = "";
343
- if (checker.checkFile(`files/${author_folder}nodes/${target}`)) {
344
- target_type = "nodes";
345
- } else if (checker.checkFile(`files/${author_folder}paths/${target}`)) {
346
- target_type = "paths";
347
- } else if (checker.checkFile(`files/${author_folder}labels/${target}`)) {
348
- target_type = "labels";
349
- }
350
-
351
- if (target_type) {
352
- target = `${target_type}/${target}`;
353
- console.log(`Target is a ${target_type.slice(0, -1)}`);
354
- } else {
355
- console.log("Warning: Target type not recognized");
353
+ if (!checker.checkFile(`files/${target}`)) {
354
+ return "Target was not found!";
356
355
  }
357
356
 
358
357
  // Encode the link data into a protocol buffer
package/package.json CHANGED
@@ -34,5 +34,5 @@
34
34
  "deprecated": false,
35
35
  "description": "![image](https://user-images.githubusercontent.com/104391124/282268780-cbbc1ee6-8d97-4d80-b896-66ae3eb723dd.png)",
36
36
  "name": "pathchain",
37
- "version": "1.1.6"
37
+ "version": "1.1.8"
38
38
  }