MCPcopy Index your code
hub / github.com/SeleniumHQ/selenium / buildPath

Function buildPath

javascript/selenium-webdriver/lib/http.js:559–579  ·  view source on GitHub ↗

* Builds a fully qualified path using the given set of command parameters. Each * path segment prefixed with ':' will be replaced by the value of the * corresponding parameter. All parameters spliced into the path will be * removed from the parameter map. * @param {string} path The original reso

(path, parameters)

Source from the content-addressed store, hash-verified

557 * @return {string} The modified path.
558 */
559function buildPath(path, parameters) {
560 let pathParameters = path.match(/\/:(\w+)\b/g)
561 if (pathParameters) {
562 for (let i = 0; i < pathParameters.length; ++i) {
563 let key = pathParameters[i].substring(2) // Trim the /:
564 if (key in parameters) {
565 let value = parameters[key]
566 if (webElement.isId(value)) {
567 // When inserting a WebElement into the URL, only use its ID value,
568 // not the full JSON.
569 value = webElement.extractId(value)
570 }
571 path = path.replace(pathParameters[i], '/' + value)
572 delete parameters[key]
573 } else {
574 throw new error.InvalidArgumentError('Missing required parameter: ' + key)
575 }
576 }
577 }
578 return path
579}
580
581// PUBLIC API
582

Callers 1

toHttpRequestFunction · 0.85

Calls 3

matchMethod · 0.45
isIdMethod · 0.45
extractIdMethod · 0.45

Tested by

no test coverage detected