public toAlias()

in src/app/files/file-nav.service.ts [137:168]


    public toAlias(path: string): string {
        if (!path) {
            return path;
        }

        //
        // Given current navigation context, get aliased path for the provided physical path

        path = path.replace(/\\/g, '/');
        let cur = !this._roots ? null : this._roots.find(r => this.normalize(path).startsWith(this.normalize(r.physical_path)));

        if (cur) {
            let suffix = path.substr(cur.physical_path.length, path.length - cur.physical_path.length);
            let start = (cur.alias || cur.name).replace(/\\/g, '/');

            if (!suffix.startsWith('/') && !start.endsWith('/')) {
                suffix = '/' + suffix;
            }

            path = start + suffix;
        }
        else {
            // Handle obtaining alias from the virtual root directory
            let root = this._files.getValue().find(f => this.normalize(f.physical_path) == this.normalize(path));

            if (root) {
                path = root.alias || root.name;
            }
        }

        return path;
    }