All files / src/files _abstract_file.ts

100% Statements 38/38
83.33% Branches 5/6
100% Functions 5/5
100% Lines 38/38

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 391x 1x 1x 1x 1x 1x 11194x 11194x 1x 1x 64693x 64693x 1x 1x 11508x 11508x 11508x 11508x 1x 1x 5754x 5754x 5754x 1x 1x 5754x 5754x 5754x 5754x 5754x 5754x 5754x 5754x 5754x 1x 1x 1x 1x  
import {IFile} from "./_ifile";
 
export abstract class AbstractFile implements IFile {
  private readonly filename: string;
 
  public constructor(filename: string) {
    this.filename = filename;
  }
 
  public getFilename(): string {
    return this.filename;
  }
 
  private baseName(): string {
    const base1 = this.getFilename().split("\\").reverse()[0];
    const base2 = base1.split("/").reverse()[0];
    return base2;
  }
 
  public getObjectType(): string | undefined {
    const split = this.baseName().split(".");
    return split[1]?.toUpperCase();
  }
 
  public getObjectName(): string {
    const split = this.baseName().split(".");
// handle url escaped namespace
    split[0] = split[0].replace(/%23/g, "#");
// handle additional escaping
    split[0] = split[0].replace(/%3e/g, ">");
    split[0] = split[0].replace(/%3c/g, "<");
// handle namespace
    return split[0].toUpperCase().replace(/#/g, "/");
  }
 
  public abstract getRaw(): string;
  public abstract getRawRows(): string[];
}