eclipse-emfcloud / emfcloud-modelserver

Modelserver component
Other
40 stars 21 forks source link

API V2: Consider using "URI" in the ModelServerClient API instead of "string" #191

Open CamilleLetavernier opened 2 years ago

CamilleLetavernier commented 2 years ago

We often have inconsistent encoding in URIs, which isn't usually an issue on Linux (Since we don't typically use special characters), but fail on Windows (Because : is a special character, and is used in all absolute file paths: c:/...).

URIs shouldn't be pre-encoded when passed the the ModelServerClient API, otherwise they will be double-encoded. However, the default behavior of URI.toString() is to encode the URI, which makes it an easy mistake for all users of the ModelServerClient API.

There are two things we can do to limit this risk:

At the moment, we need to make sure to use uri.toString(skipEncoding=true) with all ModelServerClient APIs to avoid URI encoding issues. For example:

const uri: URI = getURI();
const modeluri: string = uri.toString(/* skipEncoding =*/ true);
const patch = getPatch();
modelServerClient.edit(modeluri, patch);
eneufeld commented 2 years ago

+1 for passing URI instead of string