feat(normalsub): Implement flexible, path-based subscription URLs
Refactors the NormalSub feature to move away from a hardcoded `/sub/normal/` path and a restrictive single-word subpath. This change introduces support for multi-segment, slash-separated subpaths (e.g., `path/to/resource`), providing greater flexibility for creating descriptive and structured subscription URLs.
This commit is contained in:
@ -88,7 +88,8 @@ $(document).ready(function () {
|
||||
|
||||
function isValidSubPath(subpath) {
|
||||
if (!subpath) return false;
|
||||
return /^[a-zA-Z0-9]+$/.test(subpath);
|
||||
const subpathRegex = /^[a-zA-Z0-9]+(?:\/[a-zA-Z0-9]+)*$/;
|
||||
return subpathRegex.test(subpath);
|
||||
}
|
||||
|
||||
function isValidIPorDomain(input) {
|
||||
|
||||
@ -6,7 +6,7 @@ class StartInputBody(BaseModel):
|
||||
port: int
|
||||
|
||||
class EditSubPathInputBody(BaseModel):
|
||||
subpath: str = Field(..., min_length=1, pattern=r"^[a-zA-Z0-9]+$", description="The new subpath, must be alphanumeric.")
|
||||
subpath: str = Field(..., min_length=1, pattern=r"^[a-zA-Z0-9]+(?:/[a-zA-Z0-9]+)*$", description="The new subpath, must be alphanumeric.")
|
||||
|
||||
class GetSubPathResponse(BaseModel):
|
||||
subpath: Optional[str] = Field(None, description="The current NormalSub subpath, or null if not set/found.")
|
||||
@ -142,9 +142,13 @@
|
||||
<div class='form-group'>
|
||||
<label for='normal_subpath_input'>Subscription Path Segment:</label>
|
||||
<input type='text' class='form-control' id='normal_subpath_input'
|
||||
placeholder='e.g., mysub (becomes /mysub/...)'>
|
||||
placeholder='e.g., mysub or path/to/resource'>
|
||||
<small class="form-text text-muted">
|
||||
This path will be part of the URL. Do not use a leading or trailing slash.
|
||||
Example: <code>path/to/resource</code>
|
||||
</small>
|
||||
<div class="invalid-feedback">
|
||||
Please enter a valid subpath (alphanumeric characters only, e.g., mysub).
|
||||
Invalid format. Use alphanumeric segments separated by single slashes.
|
||||
</div>
|
||||
</div>
|
||||
<button id="normal_subpath_save_btn" type='button' class='btn btn-primary'>
|
||||
|
||||
Reference in New Issue
Block a user