All files / src/files _abstract_file.ts

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

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 40 41 42 43 44 45 46 47 48 49 50 51 52 531x 1x 1x 1x 1x 1x 35466x 35466x 1x 1x 605585x 605585x 1x 1x 37558x 37558x 37558x 37558x 37558x 37558x 37558x 37558x 37558x 37558x 37558x 37558x 37558x 37558x 1x 1x 18779x 18779x 18779x 1x 1x 18779x 18779x 18779x 18779x 18779x 18779x 18779x 18779x 18779x 18779x 18779x 18779x 18779x 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 {
    let name = this.getFilename();
 
    let index = name.lastIndexOf("\\");
    if (index) {
      index = index + 1;
    }
    name = name.substring(index);
 
    index = name.lastIndexOf("/");
    if (index) {
      index = index + 1;
    }
    return name.substring(index);
  }
 
  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 abapGit namespace
    split[0] = split[0].toUpperCase().replace(/#/g, "/");
// handle AFF namespace
    split[0] = split[0].replace("(", "/");
    split[0] = split[0].replace(")", "/");
    return split[0];
  }
 
  public abstract getRaw(): string;
  public abstract getRawRows(): string[];
}