mirror of
https://github.com/HangarMC/Hangar.git
synced 2025-02-23 15:12:52 +08:00
fix name regex configuration
This commit is contained in:
parent
5a2c474cf1
commit
1983e82e08
@ -26,3 +26,6 @@ hangar:
|
||||
api:
|
||||
url: "https://hangar-auth.minidigger.me"
|
||||
avatar-url: "https://hangar-auth.minidigger.me/avatar/%s?size=120x120"
|
||||
|
||||
projects:
|
||||
name-regex: "^[a-zA-Z0-9-_]{3,}$"
|
||||
|
@ -78,6 +78,7 @@ hangar:
|
||||
user-grid-page-size: 30
|
||||
max-keywords: 5
|
||||
unsafe-download-max-age: 10
|
||||
name-regex: "^[a-zA-Z0-9-_]{3,}$"
|
||||
|
||||
users:
|
||||
stars-per-page: 5
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.papermc.hangar.config.hangar;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -12,8 +11,8 @@ import java.util.regex.Pattern;
|
||||
@ConfigurationProperties(prefix = "hangar.projects")
|
||||
public class ProjectsConfig {
|
||||
|
||||
@Value("#{T(java.util.regex.Pattern).compile(${hangar.projects.name-regex})}")
|
||||
private Pattern nameRegex = Pattern.compile("^[a-zA-Z0-9-_]{3,}$");
|
||||
private String nameRegex = "^[a-zA-Z0-9-_]{3,}$";
|
||||
private Pattern namePattern = Pattern.compile(this.nameRegex);
|
||||
private int maxNameLen = 25;
|
||||
private int maxPages = 50;
|
||||
private int maxChannels = 5;
|
||||
@ -28,16 +27,17 @@ public class ProjectsConfig {
|
||||
private int userGridPageSize = 30;
|
||||
private Duration unsafeDownloadMaxAge = Duration.ofMinutes(10);
|
||||
|
||||
public Pattern getNameRegex() {
|
||||
public String getNameRegex() {
|
||||
return nameRegex;
|
||||
}
|
||||
|
||||
public Predicate<String> getNameMatcher() {
|
||||
return nameRegex.asMatchPredicate();
|
||||
return namePattern.asMatchPredicate();
|
||||
}
|
||||
|
||||
public void setNameRegex(Pattern nameRegex) {
|
||||
public void setNameRegex(String nameRegex) {
|
||||
this.nameRegex = nameRegex;
|
||||
this.namePattern = Pattern.compile(nameRegex);
|
||||
}
|
||||
|
||||
public int getMaxNameLen() {
|
||||
|
@ -91,6 +91,7 @@ hangar:
|
||||
user-grid-page-size: 30
|
||||
max-keywords: 5
|
||||
unsafe-download-max-age: 10
|
||||
name-regex: "^[a-zA-Z0-9-_]{3,}$"
|
||||
|
||||
users:
|
||||
stars-per-page: 5
|
||||
|
Loading…
Reference in New Issue
Block a user