api: rework url parsing
- tlds are now parsed and validated correctly (e.g. ".co.uk" works now) - url patterns are pre-compiled instead of being compiled for every request - aliases are computed in a safe manner using the URL object where possible
This commit is contained in:
@@ -1,8 +1,17 @@
|
||||
import UrlPattern from "url-pattern";
|
||||
import { loadJSON } from "./sub/loadFromFs.js";
|
||||
const config = loadJSON("./src/config.json");
|
||||
const packageJson = loadJSON("./package.json");
|
||||
const servicesConfigJson = loadJSON("./src/modules/processing/servicesConfig.json");
|
||||
|
||||
Object.values(servicesConfigJson.config).forEach(service => {
|
||||
service.patterns = service.patterns.map(
|
||||
pattern => new UrlPattern(pattern, {
|
||||
segmentValueCharset: UrlPattern.defaultOptions.segmentValueCharset + '\\.'
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
export const
|
||||
services = servicesConfigJson.config,
|
||||
audioIgnore = servicesConfigJson.audioIgnore,
|
||||
|
||||
Reference in New Issue
Block a user