• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

AleksandrRogov / DynamicsWebApi / 18876677854

28 Oct 2025 01:37PM UTC coverage: 98.334% (-0.07%) from 98.401%
18876677854

push

github

AleksandrRogov
reverting chai

674 of 707 branches covered (95.33%)

Branch coverage included in aggregate %.

2100 of 2114 relevant lines covered (99.34%)

55.98 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.92
/src/client/request/processData.ts
1
import { escapeUnicodeSymbols, removeCurlyBracketsFromUuid, removeLeadingSlash, SEARCH_FOR_ENTITY_NAME_REGEX } from "../../helpers/Regex";
1✔
2
import type { InternalConfig } from "../../utils/Config";
3
import { isNull } from "../../utils/Utility";
1✔
4
import { findCollectionName } from "../helpers";
1✔
5

6
export const processData = (data: any, config: InternalConfig): string | Uint8Array | Uint16Array | Uint32Array | null => {
1✔
7
    if (!data) return null;
290✔
8

9
    if (data instanceof Uint8Array || data instanceof Uint16Array || data instanceof Uint32Array) return data;
136✔
10

11
    const replaceEntityNameWithCollectionName = (value: string): string => {
132✔
12
        const valueParts = SEARCH_FOR_ENTITY_NAME_REGEX.exec(value);
1✔
13
        if (valueParts && valueParts.length > 2) {
1✔
14
            const collectionName = findCollectionName(valueParts[1]);
1✔
15
            if (!isNull(collectionName)) {
1✔
16
                return value.replace(SEARCH_FOR_ENTITY_NAME_REGEX, `${collectionName}$2`);
1✔
17
            }
18
        }
19
        return value;
×
20
    };
21

22
    const addFullWebApiUrl = (key: string, value: string): string => {
132✔
23
        if (!value.startsWith(config.dataApi.url)) {
7✔
24
            if (key.endsWith("@odata.bind")) {
7!
25
                if (!value.startsWith("/")) {
7✔
26
                    value = `/${value}`;
7✔
27
                }
28
            } else {
29
                value = `${config.dataApi.url}${removeLeadingSlash(value)}`;
×
30
            }
31
        }
32
        return value;
7✔
33
    };
34

35
    const stringifiedData = JSON.stringify(data, (key, value) => {
132✔
36
        if (key === "@odata.id" || key.endsWith("@odata.bind")) {
447✔
37
            if (typeof value === "string" && !value.startsWith("$")) {
19✔
38
                value = removeCurlyBracketsFromUuid(value);
13✔
39
                if (config.useEntityNames) {
13✔
40
                    value = replaceEntityNameWithCollectionName(value);
1✔
41
                }
42

43
                // the full Web API URL is only added in requests to /$ref
44
                // the value itself is set directly in the requests that require it
45
                if (key !== "@odata.id") {
13✔
46
                    value = addFullWebApiUrl(key, value);
7✔
47
                }
48
            }
49
        } else if (key.startsWith("oData") || key.endsWith("_Formatted") || key.endsWith("_NavigationProperty") || key.endsWith("_LogicalName")) {
428✔
50
            return undefined;
33✔
51
        }
52
        return value;
414✔
53
    });
54

55
    return escapeUnicodeSymbols(stringifiedData);
132✔
56
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc