-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
feat(ipv4-range-expander): expands a given IPv4 start and end address to a valid IPv4 subnet #366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… to a valid IPv4 subnet
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work thank you 🙏🏻
few changes
|
||
<script setup lang="ts"> | ||
import SpanCopyable from '@/components/SpanCopyable.vue'; | ||
import { paramCase } from 'change-case'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit]
I'd prefer using _.kebabCase
from lodash
They are more chance that I replace change-case
than lodash
😅
class Ipv4RangeExpanderResult { | ||
oldSize?: number; | ||
newStart?: string; | ||
newEnd?: string; | ||
newCidr?: string; | ||
newSize?: number; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I not fan of mixing paradigms, can you create a type (in a .type.ts file) instead of classe 🙏🏻
import { test, expect } from '@playwright/test'; | ||
|
||
test.describe('Tool - IPv4 range expander', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto('/ipv4-range-expander'); | ||
}); | ||
|
||
test('Has correct title', async ({ page }) => { | ||
await expect(page).toHaveTitle('IPv4 range expander - IT Tools'); | ||
}); | ||
|
||
test('Calculates correct for valid input', async ({ page }) => { | ||
await page.getByPlaceholder('Start IPv4 address...').fill('192.168.1.1'); | ||
await page.getByPlaceholder('End IPv4 address...').fill('192.168.7.255'); | ||
|
||
expect(await page.getByTestId('start-address.old').textContent()).toEqual('192.168.1.1'); | ||
expect(await page.getByTestId('start-address.new').textContent()).toEqual('192.168.0.0'); | ||
expect(await page.getByTestId('end-address.old').textContent()).toEqual('192.168.7.255'); | ||
expect(await page.getByTestId('end-address.new').textContent()).toEqual('192.168.7.255'); | ||
expect(await page.getByTestId('addresses-in-range.old').textContent()).toEqual('1,791'); | ||
expect(await page.getByTestId('addresses-in-range.new').textContent()).toEqual('2,048'); | ||
expect(await page.getByTestId('cidr.old').textContent()).toEqual(''); | ||
expect(await page.getByTestId('cidr.new').textContent()).toEqual('192.168.0.0/21'); | ||
}); | ||
|
||
test('Hides result for invalid input', async ({ page }) => { | ||
await page.getByPlaceholder('Start IPv4 address...').fill('192.168.1.1'); | ||
await page.getByPlaceholder('End IPv4 address...').fill('192.168.0.255'); | ||
|
||
await expect(page.getByTestId('result')).not.toBeVisible(); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for those tests 🙏🏻
</n-form-item> | ||
</n-space> | ||
|
||
<n-table v-if="showResult" data-test-id="result"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const showResult = computed( | ||
() => | ||
validationAttrsStart.validationStatus !== 'error' && | ||
validationAttrsEnd.validationStatus !== 'error' && | ||
result.value !== undefined, | ||
); | ||
const { attrs: validationAttrsStart } = useValidation({ | ||
source: rawStartAddress, | ||
rules: [{ message: 'Invalid ipv4 address', validator: (ip) => isValidIpv4({ ip }) }], | ||
}); | ||
|
||
const { attrs: validationAttrsEnd } = useValidation({ | ||
source: rawEndAddress, | ||
rules: [{ message: 'Invalid ipv4 address', validator: (ip) => isValidIpv4({ ip }) }], | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const showResult = computed( | |
() => | |
validationAttrsStart.validationStatus !== 'error' && | |
validationAttrsEnd.validationStatus !== 'error' && | |
result.value !== undefined, | |
); | |
const { attrs: validationAttrsStart } = useValidation({ | |
source: rawStartAddress, | |
rules: [{ message: 'Invalid ipv4 address', validator: (ip) => isValidIpv4({ ip }) }], | |
}); | |
const { attrs: validationAttrsEnd } = useValidation({ | |
source: rawEndAddress, | |
rules: [{ message: 'Invalid ipv4 address', validator: (ip) => isValidIpv4({ ip }) }], | |
}); | |
const showResult = computed( | |
() => | |
endIpValidation.isValid && | |
startIpValidation.isValid && | |
result.value !== undefined, | |
); | |
const startIpValidation = useValidation({ | |
source: rawStartAddress, | |
rules: [{ message: 'Invalid ipv4 address', validator: (ip) => isValidIpv4({ ip }) }], | |
}); | |
const endIpValidation = useValidation({ | |
source: rawEndAddress, | |
rules: [{ message: 'Invalid ipv4 address', validator: (ip) => isValidIpv4({ ip }) }], | |
}); |
And bind endIpValidation.attrs
* main: feat(date converter): auto focus main input
Kudos, SonarCloud Quality Gate passed!
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thank you !
Much appreciated 🙏🏻
Thank you for this. |
fixes #279