wiris / html-integrations

The official JavaScript library for MathType, the leading formula editor and equation writer for the web by Wiris
https://wiris.com/solutions/integrations/html-editors/
MIT License
76 stars 53 forks source link

Improve viewer integration services detection #979

Closed carla-at-wiris closed 4 months ago

carla-at-wiris commented 4 months ago

Description

This pull request improves the way we detect whether the user is making use of the integration services or, in its absence, wiris.net.

Prior to the development, we used a hard-coded string to identify the route where the integration services were hosted. That is a correct approach for the PHP ones, but in Java the user can change their location, making it impossible to detect since it did not match the Java hard-coded string.

The approach is to make a request to the current viewer URL, if we are not on PHP and receive an answer, it means that the client is using the Java integration services. Otherwise, it will default to wiris.net.

Steps to reproduce

Case 1:

  1. Using Plugins, deploy a Java demo with the instructions in the build/docker folder.
  2. It should load properly the viewer from the location where the integration services are. Calls are not made to wiris.net, but to localhost.

Case 2:

  1. Build and start a viewer demo with the html-integrations.
  2. Check that the mentioned request to validate if we are in Java fails, and the following requests are made to wiris.net.

#taskid 45038