diff options
author | Hsieh Chin Fan <typebrook@gmail.com> | 2021-12-13 21:50:28 +0800 |
---|---|---|
committer | Hsieh Chin Fan <typebrook@gmail.com> | 2021-12-13 21:50:28 +0800 |
commit | 2593dcdf47ec25222396f9113ca5696ec15df35e (patch) | |
tree | ddcb9c03655b19741fcdf54eea527ff1efe2ab35 | |
parent | a5ca44514fb45c24b93b9b640d43db2fbe12c16e (diff) |
Fix pattern check for token
Currently, Github might have token in the following format:
ghp_I1M4zc8z4Qi8c5KNf93KyBHGkP9Azq00Bup1
So we need to include underscore.
Also, add pattern for hyphen and consider the case more than 40
characters.
-rwxr-xr-x | gist | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -178,7 +178,7 @@ _ask_token() { | |||
178 | python -mwebbrowser https://github.com/settings/tokens/new?scopes=gist | 178 | python -mwebbrowser https://github.com/settings/tokens/new?scopes=gist |
179 | fi | 179 | fi |
180 | 180 | ||
181 | while [[ ! $token =~ ^[[:alnum:]]{40}$ ]]; do | 181 | while [[ ! $token =~ ^[[:alnum:]_-]{40,}$ ]]; do |
182 | [[ -n $token ]] && echo "Invalid token" | 182 | [[ -n $token ]] && echo "Invalid token" |
183 | read -r -p "Paste your token here (Ctrl-C to skip): " token </dev/tty | 183 | read -r -p "Paste your token here (Ctrl-C to skip): " token </dev/tty |
184 | done | 184 | done |