mirror of
https://github.com/wahyd4/links.git
synced 2026-08-09 05:06:16 +10:00
Merge pull request #67 from wahyd4/copilot/fix-test-errors-links-api
Fix alias validation rejecting valid slug characters (hyphens/underscores)
This commit is contained in:
@@ -3,6 +3,7 @@ name: Build and Deploy to Kubernetes
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
@@ -37,6 +38,7 @@ jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
needs: test
|
||||
if: github.event_name == 'push'
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
+2
-2
@@ -137,7 +137,7 @@ class LinkCreateView(CreateView):
|
||||
return super().form_valid(form)
|
||||
|
||||
def is_valid_alias(self, alias):
|
||||
return alias.isalnum()
|
||||
return bool(re.match(r'^[a-zA-Z0-9_-]+$', alias))
|
||||
|
||||
class LinkUpdateView(UpdateView):
|
||||
model = Link
|
||||
@@ -218,7 +218,7 @@ class LinkUpdateView(UpdateView):
|
||||
return reverse('link_detail', kwargs={'pk': self.object.pk})
|
||||
|
||||
def is_valid_alias(self, alias):
|
||||
return alias.isalnum()
|
||||
return bool(re.match(r'^[a-zA-Z0-9_-]+$', alias))
|
||||
|
||||
class LinkDeleteView(DeleteView):
|
||||
model = Link
|
||||
|
||||
Reference in New Issue
Block a user