+
Skip to content

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

Merged
merged 6 commits into from
Apr 19, 2023

Conversation

cgoIT
Copy link
Contributor

@cgoIT cgoIT commented Apr 19, 2023

fixes #279

@vercel
Copy link

vercel bot commented Apr 19, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
it-tools ✅ Ready (Inspect) Visit Preview Apr 19, 2023 6:26pm

Copy link
Owner

@CorentinTh CorentinTh left a 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';
Copy link
Owner

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 😅

Comment on lines 3 to 9
class Ipv4RangeExpanderResult {
oldSize?: number;
newStart?: string;
newEnd?: string;
newCidr?: string;
newSize?: number;
}
Copy link
Owner

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 🙏🏻

Comment on lines +1 to +32
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();
});
});
Copy link
Owner

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">
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a feedback when ip are valid but their is no result since range is invalid please

image

Comment on lines 75 to 89
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 }) }],
});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Owner

@CorentinTh CorentinTh left a 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 🙏🏻

@CorentinTh CorentinTh merged commit df989e2 into CorentinTh:main Apr 19, 2023
@TCB13
Copy link

TCB13 commented Apr 19, 2023

Thank you for this.

@cgoIT cgoIT deleted the feat/ipv4-range-expander branch April 20, 2023 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] Networking Tools
3 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载