Last active
March 26, 2020 15:29
-
-
Save meto4d/d518f4fdcc08e2d7a6cde2869d1086d7 to your computer and use it in GitHub Desktop.
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
//汎用URLパターン | |
var URL_PATTERN = /^(\w+):\/\/((\w|\.|:)+)(\/(.*))?$/ | |
//したらば | |
var SHITARABA_URL_PATTERN = /^https?:\/\/jbbs\.shitaraba\.net.*$/ | |
var SHITARABA_THREAD_URL_PATTERN = /^https?:\/\/jbbs\.shitaraba\.net\/bbs\/read\.cgi\/(\w+)\/(\d+)\/(\d+)(:?|\/.*)$/; | |
var SHITARABA_BOARD_URL_PATTERN = /^https?:\/\/jbbs\.shitaraba\.net\/(\w+)\/(\d+)\/?$/; | |
//2ch系列 | |
var NICHAN_THREAD_URL_PATTERN = /^https?:\/\/(?!jbbs\.shitaraba\.net)(.+)\/test\/read\.cgi\/(\w+)\/(\d+)\/(:?|\/.*)$/; | |
var NICHAN_BOARD_URL_PATTERN = /^https?:\/\/(?!jbbs\.shitaraba\.net)(.+)\/(\w+)\/?$/; | |
//複合汎用掲示板 | |
var THREAD_URL_PATTERN = /^(\w+):\/\/([^\/]+)\/(test|bbs)\/read\.cgi\/(\w+)\/(\d+)(\/(\d+))?(:?|\/.*)$/; | |
var BOARD_URL_PATTERN = /^(\w+):\/\/([^\/]+)\/(\w+)(\/(\d+))?\/?$/; | |
var match = THREAD_URL_PATTERN.exec(CONTACT_URL); | |
function thread_url(match) { | |
var url = {}; | |
url.protocol = match[1]; | |
url.shitaraba = ~match[2].indexOf("shitaraba"); | |
url.fqdn = match[2]; | |
url.category = match[4]; | |
url.board_num = url.shitaraba ? match[5] : ""; | |
url.thread_id = url.shitaraba ? match[7] : match[5]; | |
return url; | |
} | |
var match = BOARD_URL_PATTERN.exec(CONTACT_URL); | |
function board_url(match) { | |
var url = {}; | |
url.protocol = match[1]; | |
url.shitaraba = ~match[2].indexof("shitaraba"); | |
url.fqdn = match[2]; | |
url.category = match[3]; | |
url.board_num = url.shitaraba ? match[5] : ""; | |
return url; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment