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

Export utilities APIs to public and minor fixes #32

Merged
merged 5 commits into from
Aug 22, 2024

Conversation

mitsuki31
Copy link
Owner

Overview

This pull request introduces several enhancements, including the addition of new utility APIs, improvements to the YouTube URL regex, and minor fixes to existing modules. The changes aim to provide developers with more robust tools for working with YouTube URLs and handling errors effectively.

Key Changes

New Features

  • Added and exported the following standalone API functions:
    • extractVideoId: Extracts the video ID from a YouTube URL.
      function extractVideoId(url: string | URL): string;
    • validateUrl: Validates whether a given URL is a valid YouTube URL.
      function validateUrl(url: string | URL): boolean;
    • validateId: Validates whether a given string is a valid YouTube video ID.
      function validateId(id: string): boolean;
  • Exported all custom error classes from the error module, providing more robust error handling capabilities. This includes:
    • IDExtractorError
      class IDExtractorError extends Error {}
    • UnknownOptionError
      class UnknownOptionError extends Error {}
  • Exported the YTURLUtils class (aliased from URLUtils), which offers static methods for developers working with YouTube URLs.

Refactors

  • Improved the regular expression used for YouTube URL validation to make it more accurate and reliable.

Fixes

  • Corrected the exports statement in the error module to ensure all custom error classes are exported properly.
    Previously, when attempt to import the error module, the returned object is an empty object ({}).

Test Environments

  • Updated test cases to use the IDExtractorError class, replacing the previous string representation of the class name with the actual class.

Summary

These updates enhance the flexibility and reliability of the ytmp3 module by introducing new utility APIs and refining existing components. The improved YouTube URL validation regex and corrected export statements ensure a smoother experience for developers integrating YouTube functionalities into their projects. The added utilities and error handling enhancements will help prevent common issues and streamline the development process.

Replaced the expected error to use actual class instead a string representing the class name.
* Included and exported the `extractVideoId`, `validateUrl`, and `validateId` functions as standalone API functions
* Included and exported all custom error class from `lib/error` module
* Exported the `YTURLUtils` (aliased from `URLUtils`) class for develoers working with YouTube URLs
@mitsuki31 mitsuki31 added refactor Refactor and enhancement changes bugfix Fixes any issue and bug feature Bring new features minor Minor changes labels Aug 21, 2024
@mitsuki31 mitsuki31 self-assigned this Aug 21, 2024
@mitsuki31 mitsuki31 force-pushed the feature/add-utils-apis-and-minor-fixes branch from 75c61bd to 5d34846 Compare August 22, 2024 04:12
@mitsuki31 mitsuki31 merged commit f6c0068 into master Aug 22, 2024
9 checks passed
@mitsuki31 mitsuki31 deleted the feature/add-utils-apis-and-minor-fixes branch August 22, 2024 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Fixes any issue and bug feature Bring new features minor Minor changes refactor Refactor and enhancement changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant