MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / encodeExtension

Function encodeExtension

javascript/selenium-webdriver/lib/web_extension.js:116–128  ·  view source on GitHub ↗

* The extension as base64 bytes: a directory is zipped, a file read, and anything else is * taken to already be base64-encoded. * @param {string} extension * @return {!Promise }

(extension)

Source from the content-addressed store, hash-verified

114 * @return {!Promise<string>}
115 */
116async function encodeExtension(extension) {
117 checkExtensionArg(extension)
118 const stats = await statOrNull(extension)
119 if (stats?.isDirectory()) {
120 const zip = new Zip()
121 await zip.addDir(extension)
122 return (await zip.toBuffer('DEFLATE')).toString('base64')
123 }
124 if (stats?.isFile()) {
125 return (await fs.readFile(extension)).toString('base64')
126 }
127 return asBase64(extension)
128}
129
130/**
131 * The BiDi `webExtension.ExtensionData` for `extension`. A directory only resolves on the

Callers 1

extensionDataFunction · 0.85

Calls 9

addDirMethod · 0.95
toBufferMethod · 0.95
checkExtensionArgFunction · 0.85
statOrNullFunction · 0.85
asBase64Function · 0.85
readFileMethod · 0.80
isDirectoryMethod · 0.65
toStringMethod · 0.65
isFileMethod · 0.45

Tested by

no test coverage detected