All files / src/files _abstract_file.ts

100% Statements 13/13
75% Branches 3/4
100% Functions 5/5
100% Lines 13/13

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    1x       10813x       61109x       11044x 11044x 11044x       5522x 5522x       5522x   5522x   5522x 5522x   5522x            
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[];
}