Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/common/src/restHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2107,13 +2107,14 @@ export function _countRelationships(layers: any[]): number {

/**
* Remove spaces and replace other characters that are not allowed in a feature service name with "_".
* Spaces are removed entirely. Disallowed (replaced with "_"): '#', '%', '&', '"', '\', '/', '+', '?', ':', '*', '<', '>', '\t'
* Spaces are removed entirely. Disallowed (replaced with "_"): '#', '%', '&', '"', '\', '/', '+', '?', ':', '*',
* '<', '>', '\t', '!', '@', "'", ';', ','
*
* @param name The candidate service name
* @returns The sanitized name, or the input unchanged if it is not a string
*/
export function sanitizeFeatureServiceName(name: string): string {
return typeof name === "string" ? name.replace(/ /g, "").replace(/[#%&"\\/+?:*<>\t]/g, "_") : name;
return typeof name === "string" ? name.replace(/ /g, "").replace(/[#%&"\\/+?:*<>\t!@';,]/g, "_") : name;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/common/test/restHelpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4613,8 +4613,8 @@ describe("Module `restHelpers`: common REST utility functions shared across pack

describe("sanitizeFeatureServiceName", () => {
it("removes spaces and replaces every other disallowed character with '_'", () => {
const disallowedName = 'a#b%c&d"e\\f/g+h?i:j*k<l>m n\to';
expect(restHelpers.sanitizeFeatureServiceName(disallowedName)).toEqual("a_b_c_d_e_f_g_h_i_j_k_l_mn_o");
const disallowedName = "a#b%c&d\"e\\f/g+h?i:j*k<l>m n\to!p@q'r;s,t";
expect(restHelpers.sanitizeFeatureServiceName(disallowedName)).toEqual("a_b_c_d_e_f_g_h_i_j_k_l_mn_o_p_q_r_s_t");
});

it("returns allowed names unchanged", () => {
Expand Down
Loading