All files / src/Ice IdentityToString.js

100% Statements 25/25
100% Branches 4/4
100% Functions 1/1
100% Lines 25/25

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 2641x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 3161x 3081x 3161x 80x 80x 80x 80x 80x 80x 3161x  
// Copyright (c) ZeroC, Inc.
 
import { ToStringMode } from "./ToStringMode.js";
import { StringUtil } from "./StringUtil.js";
 
/**
 * Converts an object identity to a string.
 *
 * @param ident The object identity to convert.
 *
 * @param toStringMode Specifies if and how non-printable ASCII characters are escaped in the result.
 *
 * @return The string representation of the object identity.
 */
export function identityToString(ident, toStringMode = ToStringMode.Unicode) {
    if (ident.category === null || ident.category.length === 0) {
        return StringUtil.escapeString(ident.name, "/", toStringMode);
    } else {
        return (
            StringUtil.escapeString(ident.category, "/", toStringMode) +
            "/" +
            StringUtil.escapeString(ident.name, "/", toStringMode)
        );
    }
}