Arxiv { static public String url2num(String url) { if (!url.startsWith(ARXIV_NS)) { if (!url.startsWith(ARXIV_NS_OLD)) { return null; } else { url = "https:" + url.substring(5); } } String x = null; int k = url.indexOf("#"); if (k > 0) url = url.substring(0,k); k = url.indexOf("?"); if (k > 0) url = url.substring(0,k); if (url.startsWith(ABS)) { x = url.substring(ABS_LEN); } else if (url.startsWith(PDF)) { x = url.substring(PDF_LEN); x = x.substring(0, x.length()-4); } else { return null; } k = x.indexOf("v"); if (k>0) { x = x.substring(0,k); } return x; }  static String url2num(String url); static String url2pdfUrl(String url); static String sldoc2arxivNum(SLDocument doc, SLModel mod);  }
@Test public void url2numTest() { String num = "2003.02320"; String url = "https: String x; x = Arxiv.url2num(url); assertTrue(num.contentEquals(x)); url = "https: x = Arxiv.url2num(url); assertTrue(num.contentEquals(x)); url = "https: x = Arxiv.url2num(url); System.out.println(x); assertTrue(num.contentEquals(x)); url = "http: x = Arxiv.url2num(url); System.out.println(x); assertTrue("0811.3701".contentEquals(x)); }
@Test public void numIfBookmarkWithHash() { String url = "https: String num = Arxiv.url2num(url); assertTrue(num.equals("1912.08904")); }