All files / src/files _abstract_file.ts

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

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 39 401x 1x 1x 1x 1x 1x 13829x 13829x 1x 1x 88333x 88333x 1x 1x 14774x 14774x 14774x 14774x 14774x 1x 1x 7387x 7387x 7387x 1x 1x 7387x 7387x 7387x 7387x 7387x 7387x 7387x 7387x 7387x 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 first = this.getFilename().split("\\");
    const base1 = first[ first.length - 1 ];
    const base2 = base1.split("/");
    return base2[ base2.length - 1 ];
  }
 
  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[];
}