Skip to content

Commit

Permalink
feat: added validation to <branch-config>
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanneff committed Mar 2, 2017
1 parent 55ed145 commit 9f440ac
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions hooks/lib/sdk/configXml.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,21 @@
if (preferences.branchKey === null) {
throw new Error('BRANCH SDK: Missing "branch-key" in <branch-config> in your config.xml. https://goo.gl/GijGKP')
}
if (preferences.uriScheme === null) {
throw new Error('BRANCH SDK: Missing "uri-scheme" in <branch-config> in your config.xml. https://goo.gl/GijGKP')
if (preferences.uriScheme === null || !/^[a-zA-Z0-9-.]*$/.test(preferences.uriScheme)) {
throw new Error('BRANCH SDK: Invalid "uri-scheme" in <branch-config> in your config.xml. Docs https://goo.gl/GijGKP')
}
if (preferences.linkDomain === null) {
throw new Error('BRANCH SDK: Missing "uri-scheme" in <branch-config> in your config.xml. https://goo.gl/GijGKP')
if (preferences.linkDomain === null || !/^(?!.*?www).*([a-zA-Z0-9]+(\.[a-zA-Z0-9]+)+.*)$/.test(preferences.linkDomain)) {
throw new Error('BRANCH SDK: Invalid "link-domain" in <branch-config> in your config.xml. Docs https://goo.gl/GijGKP')
}
if (preferences.iosTeamRelease === null || !/^[a-zA-Z0-9]{10}$/.test(preferences.iosTeamRelease)) {
throw new Error('BRANCH SDK: Invalid "ios-team-release" in <branch-config> in your config.xml. Docs https://goo.gl/GijGKP')
}
if (preferences.iosTeamDebug !== null && !/^[a-zA-Z0-9]{10}$/.test(preferences.iosTeamDebug)) {
throw new Error('BRANCH SDK: Invalid "ios-team-debug" in <branch-config> in your config.xml. Docs https://goo.gl/GijGKP')
}
if (preferences.androidPrefix !== null && !/^[/].[a-zA-Z0-9]{3}$/.test(preferences.androidPrefix)) {
throw new Error('BRANCH SDK: Invalid "android-prefix" in <branch-config> in your config.xml. Docs https://goo.gl/GijGKP')
}
if (preferences.iosTeamProd === null) {
throw new Error('BRANCH SDK: Missing "ios-team-prod" in <branch-config> in your config.xml. https://goo.gl/GijGKP')
if (!(preferences.androidTestMode === 'true' || preferences.androidTestMode === 'false')) {
throw new Error('BRANCH SDK: Invalid "android-testmode" in <branch-config> in your config.xml. Docs https://goo.gl/GijGKP')
}
Expand Down

0 comments on commit 9f440ac

Please sign in to comment.