Skip to content
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

Refactor YouTube URL validator and introduce utility modules #29

Merged
merged 5 commits into from
Aug 20, 2024

Conversation

mitsuki31
Copy link
Owner

Overview

This pull request introduces significant improvements to the YouTube URL validation process by replacing the previous regex-based validation with a more robust and reliable method. Additionally, several utility modules were added and refactored to enhance the maintainability and functionality of the project.

Key Changes

Features

  • Introduced a new url-utils module that provides a utility class with static methods for working with YouTube URLs.
    The module includes methods for URL validation and video ID extraction, aiming to offer a more accurate and strict validation process compared to using regular expressions alone.
  • Added an alias to the exports: log is now aliased from logger to improve code readability.
  • Introduced a new error module containing all custom error classes used within the project.

Refactors

  • Replaced the previous regex-based YouTube URL validation with the newly introduced function-based validation method (URLUtils.validateUrl), ensuring more reliable URL handling.
  • Re-sorted the members of the utils module and updated the documentation accordingly to ensure a cleaner and more organized structure.
  • Moved the IDExtractionError and UnknownOptionError classes to the new error module, centralizing error management.

Testing

  • Added a comprehensive test suite for the url-utils module to ensure the reliability and accuracy of the new URL validation and extraction methods.

Impact

  • Improves the reliability and strictness of YouTube URL validation across the application.
  • Enhances code organization and maintainability by introducing dedicated utility and error modules.
  • Strengthens the overall codebase with added tests, reducing the likelihood of bugs and issues related to URL validation.

This refactor is a crucial step in making the project more robust, reliable, and easier to maintain, especially concerning YouTube URL handling.

This module provides utility static class for working with YouTube URLs more easy and reliable, offering static methods for URL validation and video ID extraction. This module is aimed to improve the YouTube URL validation and more strict rather using only regular expression.
Replace the regex-based validation to function-based instead (`URLUtils.validateUrl`).
* Added an alias to exports: `log` aliased from `logger`
* Re-sorted the module's members and documentations
* Added `error` module containing all custom error classes
* Moved the `IDExtractionError` and `UnknownOptionError` class to `error` module
* Resolve unused variable within try-catch block in `URLUtils.validateUrl` method
@mitsuki31 mitsuki31 added refactor Refactor and enhancement changes minor Minor changes labels Aug 20, 2024
@mitsuki31 mitsuki31 self-assigned this Aug 20, 2024
@mitsuki31 mitsuki31 merged commit 2b13b96 into master Aug 20, 2024
15 checks passed
@mitsuki31 mitsuki31 deleted the refactor/youtube-url-validator-improvisation branch August 20, 2024 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor Minor changes refactor Refactor and enhancement changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant