@pnp/sp
Version:
pnp - provides a fluent api for working with SharePoint REST
18 lines • 715 B
JavaScript
import { stringIsNullOrEmpty } from "@pnp/core";
export function escapeQueryStrValue(value) {
if (stringIsNullOrEmpty(value)) {
return "";
}
// replace all instance of ' with ''
if (/!(@.*?)::(.*?)/ig.test(value)) {
// to ensure our param aliasing still works we need to treat these special or we'll hear about it
// so we encode JUST the part that will end up in the url
return value.replace(/!(@.*?)::(.*)$/ig, (match, labelName, v) => {
return `!${labelName}::${encodeURIComponent(v.replace(/'/ig, "''"))}`;
});
}
else {
return encodeURIComponent(value.replace(/'/ig, "''"));
}
}
//# sourceMappingURL=escape-query-str.js.map