Skip to content

Commit

Permalink
Merge pull request #178 from Vizzuality/fix/url-bug
Browse files Browse the repository at this point in the history
new regex to url
  • Loading branch information
mluena authored Feb 6, 2025
2 parents 728d172 + 3764440 commit 988b9f3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 41 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/e2e_client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: actions/checkout@v4

- name: Node setup
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: 'client/.nvmrc'
cache: yarn
Expand All @@ -44,7 +44,7 @@ jobs:
# Recommended: pass the GitHub token lets this action correctly
# determine the unique run id necessary to re-run the checks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
Expand Down
64 changes: 32 additions & 32 deletions client/.github/workflows/e2e-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: e2e_client
on:
push:
paths:
- 'client/**'
- '.github/workflows/e2e-client.yml'
- '!client/README.md'
- "client/**"
- ".github/workflows/e2e-client.yml"
- "!client/README.md"

jobs:
e2e_client:
Expand All @@ -16,37 +16,37 @@ jobs:
run:
working-directory: client
steps:
- name: checkout pull
uses: actions/checkout@v3
- name: checkout pull
uses: actions/checkout@v4

- name: Node setup
uses: actions/setup-node@v3
with:
node-version-file: 'client/.nvmrc'
cache: yarn
cache-dependency-path: 'client/yarn.lock'
- name: Node setup
uses: actions/setup-node@v4
with:
node-version-file: "client/.nvmrc"
cache: yarn
cache-dependency-path: "client/yarn.lock"

- name: Changes Yarn version
run: corepack enable
- name: Changes Yarn version
run: corepack enable

- name: Install dependencies
run: yarn install --immutable
- name: Install dependencies
run: yarn install --immutable

- name: Install Playwright Browsers
run: yarn playwright install --with-deps
- name: Install Playwright Browsers
run: yarn playwright install --with-deps

- name: Run Playwright tests
run: yarn playwright test
env:
NEXT_PUBLIC_URL: http://localhost:3000
NEXT_PUBLIC_API_URL: http://localhost:1337/cms
NEXT_PUBLIC_MAPBOX_API_TOKEN: ${{ secrets.NEXT_PUBLIC_MAPBOX_API_TOKEN }}
# Recommended: pass the GitHub token lets this action correctly
# determine the unique run id necessary to re-run the checks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
- name: Run Playwright tests
run: yarn playwright test
env:
NEXT_PUBLIC_URL: http://localhost:3000
NEXT_PUBLIC_API_URL: http://localhost:1337/cms
NEXT_PUBLIC_MAPBOX_API_TOKEN: ${{ secrets.NEXT_PUBLIC_MAPBOX_API_TOKEN }}
# Recommended: pass the GitHub token lets this action correctly
# determine the unique run id necessary to re-run the checks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
15 changes: 8 additions & 7 deletions client/src/containers/other-tools/form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,14 @@ export default function ToolForm() {

const formSchema = z.object({
name: z.string().min(1, { message: "Please enter tool name" }),
link: z.string().refine(
(value) => {
// This regex requires the URL to start with either http://, https://, or www.
return /^(https?:\/\/|www\.)[a-zA-Z0-9-]+\.[a-zA-Z]{2,}(\/[^\s]*)?$/.test(value);
},
{ message: "Please enter a valid URL" },
),
link: z
.string()
.regex(
new RegExp(
"^(https?:\\/\\/)?(www\\.)?[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)+(\\/[a-zA-Z0-9-]*)*$",
),
{ message: "Please enter a valid URL" },
),
category: z
.number()
.optional()
Expand Down

0 comments on commit 988b9f3

Please sign in to comment.