Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes Made:
1.URL Decoding: Previously, the application used URL strings directly without decoding them, leading to invalid URL errors. In this update, URL decoding using decodeURIComponent() has been implemented before fetching content from each URL. This ensures that special characters in the URLs are properly decoded, preventing "Invalid URL" errors.
2.Error Handling Enhancement: Error handling has been improved by adding try...catch blocks around the code responsible for fetching and parsing content from each URL. This allows catching and logging any errors that occur during the process, preventing the application from crashing due to unhandled exceptions.
3.Filtered Source Check: After processing the sources, a check has been added to filter out any sources that might be null (e.g., if there was an error fetching or parsing content from a particular URL). This ensures that only valid sources are further processed, avoiding potential issues.
4.Text Slicing: After cleaning the text content of each source, a check has been added to ensure that the text is sliced to a maximum length of 1500 characters. This helps in limiting the size of the text and prevents excessively long text from being returned in the response.