chore: rename url to route in shouldAvoidProxy
MODIFY
packages/appium-plugins/packages/base/README.md
packages/appium-plugins/packages/base/README.md
@@ -95,9 +95,9 @@ You might find yourself in a position where you want to handle *all* commands, i
There is a bit of a gotcha with handling Appium commands. Appium drivers have the ability to turn on a special 'proxy' mode, wherein the Appium server process takes a look at incoming URLs, and decides whether to forward them on to some upstream WebDriver server. It could happen that a command which a plugin wants to handle is designated as a command which is being proxied to an upstream server. In this case, we run into a problem, because the plugin never gets a chance to handle that command! For this reason, plugins can implement a special member function called `shouldAvoidProxy`, which takes the following parameters:
-1. `method`
-2. `url`
-3. `body`
+1. `method` - string denoting HTTP method (`GET`, `POST`, etc...)
+2. `route` - string denoting the requested resource, for example `/session/8b3d9aa8-a0ca-47b9-9ab7-446e818ec4fc/source`
+3. `body` - optional value of any type representing the WebDriver request body
These parameters define an incoming request. If you want to handle a command in your plugin which would normally be proxied directly through a driver, you could disable or 'avoid' proxying the request, and instead have the request fall into the typical Appium command execution flow (and thereby your own command function). To avoid proxying a request, just return `true` from `shouldAvoidProxy`. Some examples of how this method is used are in the [Universal XML plugin](../universal-xml/lib/plugin.js) (where we want to avoid proxying the `getPageSource` command, or in the [Images plugin](../images/lib/plugin.js) (where we want to conditionally avoid proxying any command if it looks like it contains an image element).

MODIFY
packages/appium-plugins/packages/images/lib/plugin.js
packages/appium-plugins/packages/images/lib/plugin.js
@@ -47,12 +47,12 @@ export default class ImageElementPlugin extends BasePlugin {
},
};
- shouldAvoidProxy (method, url, body) {
+ shouldAvoidProxy (method, route, body) {
// if it looks like we have an image element in the url (as a route
// parameter), never proxy. Just look for our image element prefix in allowed
// positions (either after an 'element' or 'screenshot' path segment), and
// ensure the prefix is followed by something
- if (IMG_EL_URL_RE.test(url)) {
+ if (IMG_EL_URL_RE.test(route)) {
return true;
}

MODIFY
packages/appium-plugins/packages/universal-xml/lib/plugin.js
packages/appium-plugins/packages/universal-xml/lib/plugin.js
@@ -15,8 +15,8 @@ export default class UniversalXMLPlugin extends BasePlugin {
// we don't want the UIA2 driver to proxy source requests directly to the UIA2 server, since we
// want to handle the source command ourselves
- shouldAvoidProxy (method, url) {
- return method === 'GET' && SOURCE_URL_RE.test(url);
+ shouldAvoidProxy (method, route) {
+ return method === 'GET' && SOURCE_URL_RE.test(route);
}
async getPageSource (next, driver, sessId, addIndexPath = false) {

chore: rename url to route in shouldAvoidProxy