aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHsieh Chin Fan <typebrook@gmail.com>2021-12-13 21:50:28 +0800
committerHsieh Chin Fan <typebrook@gmail.com>2021-12-13 21:50:28 +0800
commit2593dcdf47ec25222396f9113ca5696ec15df35e (patch)
treeddcb9c03655b19741fcdf54eea527ff1efe2ab35
parenta5ca44514fb45c24b93b9b640d43db2fbe12c16e (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-xgist2
1 files changed, 1 insertions, 1 deletions
diff --git a/gist b/gist
index c2f6e5f..c38d5b8 100755
--- a/gist
+++ b/gist
@@ -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