-
-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
778d590
commit 333ef29
Showing
13 changed files
with
102 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
const W3C_ELEMENT = `element-6066-11e4-a52e-4f735466cecf`; | ||
import _ from 'lodash'; | ||
import { util } from '@appium/support'; | ||
|
||
export const decode = (input: string | {ELEMENT: string}): string => { | ||
let base64String = ``; | ||
if (typeof input === `string`) { | ||
if (_.isString(input)) { | ||
base64String = input; | ||
} else if (typeof input === `object` && input[W3C_ELEMENT]) { | ||
base64String = input[W3C_ELEMENT]; | ||
} else if (typeof input === `object` && input.ELEMENT) { | ||
} else if (_.has(input, util.W3C_WEB_ELEMENT_IDENTIFIER)) { | ||
base64String = input[util.W3C_WEB_ELEMENT_IDENTIFIER]; | ||
} else if (_.has(input, 'ELEMENT')) { | ||
base64String = input.ELEMENT; | ||
} else { | ||
throw new Error(`input is invalid ${JSON.stringify(input)}`); | ||
throw new Error( | ||
`Input is is expceted to be a base64-encoded string or a valid element object. ` + | ||
`${JSON.stringify(input)} has been provided instead`); | ||
} | ||
return Buffer.from(base64String, `base64`).toString(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.