Commit 2de17439 authored by nanahira's avatar nanahira

adapt digit usernames

parent 435b2ceb
...@@ -19,7 +19,7 @@ const https_server = https.createServer(https_options, (request, response) => { ...@@ -19,7 +19,7 @@ const https_server = https.createServer(https_options, (request, response) => {
} }
//const username = encodeURIComponent(path_match[1]); //const username = encodeURIComponent(path_match[1]);
const username = path_match[1]; const username = path_match[1];
console.log("REQUEST", username); //console.log("REQUEST", username);
_request({ _request({
url: "https://ygobbs.com/users/" + username + ".json", url: "https://ygobbs.com/users/" + username + ".json",
json: true json: true
...@@ -33,13 +33,13 @@ const https_server = https.createServer(https_options, (request, response) => { ...@@ -33,13 +33,13 @@ const https_server = https.createServer(https_options, (request, response) => {
response.end("Bad username JSON."); response.end("Bad username JSON.");
console.error("BAD USERNAME JSON", body); console.error("BAD USERNAME JSON", body);
} else if (!body.users) { } else if (!body.users) {
console.log("FALLBACK", username); //console.log("FALLBACK", username);
request_avatar(response, username); request_avatar(response, username);
} else { } else {
const real_user = body.users[0].username; const real_user = body.user.username;
var real_username = encodeURIComponent(real_user); var real_username = encodeURIComponent(real_user);
if (real_user.match(/[a-z0-9]{20}/)) { //random username if (real_user.match(/[a-z0-9]{20}/)) || (real_user.match(/[0-9]{1,6}/)) { //random username
real_username = encodeURIComponent(body.users[0].name); real_username = encodeURIComponent(body.user.name);
} }
request_avatar(response, real_username); request_avatar(response, real_username);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment