{"record":{"id":"4ccb7e48fe650ce2","repo":"languagetool-org/languagetool","slug":"url-does-not-seem-to-be-a-valid-wikipedia-url-u","errorCode":null,"errorMessage":"URL does not seem to be a valid Wikipedia URL: + url","messagePattern":"URL does not seem to be a valid Wikipedia URL: \\+ url","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-wikipedia/src/main/java/org/languagetool/dev/wikipedia/WikipediaQuickCheck.java","lineNumber":111,"sourceCode":"  public Language getLanguage(URL url) {\n    Matcher matcher = getUrlMatcher(url.toString());\n    return Languages.getLanguageForShortCode(matcher.group(1));\n  }\n\n  public String getPageTitle(URL url) {\n    Matcher matcher = getUrlMatcher(url.toString());\n    return matcher.group(2);\n  }\n  \n  private Matcher getUrlMatcher(String url) {\n    Matcher matcher1 = WIKIPEDIA_URL_REGEX.matcher(url);\n    Matcher matcher2 = SECURE_WIKIPEDIA_URL_REGEX.matcher(url);\n    if (matcher1.matches()) {\n      return matcher1;\n    } else if (matcher2.matches()) {\n      return matcher2;\n    }\n    throw new RuntimeException(\"URL does not seem to be a valid Wikipedia URL: \" + url);\n  }\n\n  public void setDisabledRuleIds(List<String> ruleIds) {\n    disabledRuleIds = ruleIds;\n  }\n  \n  public List<String> getDisabledRuleIds() {\n    return disabledRuleIds;\n  }\n\n  public MarkupAwareWikipediaResult checkPage(URL url) throws IOException, PageNotFoundException {\n    return checkPage(url, null);\n  }\n\n  /**\n   * @since 2.6\n   */\n  public MarkupAwareWikipediaResult checkPage(URL url, ErrorMarker errorMarker) throws IOException, PageNotFoundException {","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-wikipedia/src/main/java/org/languagetool/dev/wikipedia/WikipediaQuickCheck.java#L93-L129","documentation":"WikipediaQuickCheck validates the given URL against regular expressions for regular and secure (https) Wikipedia URLs. If neither matches, getUrlMatcher throws a RuntimeException stating the URL does not look like a valid Wikipedia URL.","triggerScenarios":"Passing a non-Wikipedia URL, a URL with an unexpected host pattern (e.g. wikimedia project other than wikipedia, mobile domain, or missing language subdomain) to the quick-check entry point.","commonSituations":"Using https://simple.wiktionary.org or another Wikimedia project instead of *.wikipedia.org; typos in the domain; very new domain forms not covered by the bundled regexes.","solutions":["Use a standard Wikipedia URL of the form http(s)://<lang>.wikipedia.org/...","Check for typos in the URL/domain","Update the SECURE/regular Wikipedia URL regex patterns to cover the URL form you use","Pre-validate the URL against the supported pattern in your own code before calling"],"exampleFix":"// before\nString url = \"https://de.wiktionary.org/wiki/Haus\";\n// after\nString url = \"https://de.wikipedia.org/wiki/Haus\";","handlingStrategy":"validation","validationCode":"private static final Pattern WIKI = Pattern.compile(\"https?://[a-z-]+\\\\.wikipedia\\\\.org/.*\");\nif (url == null || !WIKI.matcher(url).matches()) throw new IllegalArgumentException(\"not a wikipedia URL\");","typeGuard":"boolean isWikipediaUrl(String url) { return url != null && WIKIPEDIA_URL_REGEX.matcher(url).matches(); }","tryCatchPattern":"try {\n  Matcher m = quickCheck.getUrlMatcher(url);\n} catch (RuntimeException e) {\n  System.err.println(\"Please provide a URL like https://en.wikipedia.org/wiki/...\");\n}","preventionTips":["Only pass *.wikipedia.org URLs (not other Wikimedia projects)","Sanitize URLs copied from browsers (strip anchors/extra params if unsupported)","Re-check regex coverage when new Wikipedia URL forms appear"],"tags":["url-validation","wikipedia","regex"],"backgroundTag":"invalid-url-format","analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}