diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 549f4f8..0df0764 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -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 diff --git a/links/views.py b/links/views.py index 1a5fe0c..69b7d90 100644 --- a/links/views.py +++ b/links/views.py @@ -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