arcgis-rest-js icon indicating copy to clipboard operation
arcgis-rest-js copied to clipboard

getItemResource strips out some whitespace characters

Open skitterm opened this issue 3 years ago • 1 comments

When using getItemResource to request a resource (instead of the generic request), special whitespace is not preserved (in this case, the non-breaking-space character).

Digging deeper, it seems that getItemResource is either not passing needed parameters (it doesn't include f:json in the form data for a POST request), or is unintentionally stripping out the whitespaces after receiving the server's response.

Here's a repro case (see the console logs when clicking the buttons -- 1 output includes space, one does not): https://jsfiddle.net/pktgv32d/2/

skitterm avatar Jan 24 '22 19:01 skitterm

Thank you for the report. ArcGIS REST JS does indeed scrub "control characters" for getItemResource() calls when readAs is json:

https://github.com/Esri/arcgis-rest-js/blob/090e3a590142d40b32390bf1d4775e7d0be876bd/packages/arcgis-rest-portal/src/items/get.ts#L226-L237 -> https://github.com/Esri/arcgis-rest-js/blob/090e3a590142d40b32390bf1d4775e7d0be876bd/packages/arcgis-rest-portal/src/items/get.ts#L441-L445

In this case, the "space" you're seeing is actually a control character - you can see that if you copy the text from https://www.arcgis.com/sharing/rest/content/items/30a6ffeffe494566b52eca2e29bdb5fd/resources/published_data.json into somewhere you can see the values, like SublimeText:

image

So I think in this case REST JS is doing what it's supposed to. Do you know how this text that contains the <0xa0> control character was generated?

gavinr avatar Jun 20 '22 16:06 gavinr

Closing this due to lack of activity. If any more info please post here and we can re-open.

gavinr avatar Sep 20 '22 16:09 gavinr