Skip to content

Conversation

bnodir
Copy link
Contributor

@bnodir bnodir commented Oct 31, 2024

Purpose

This PR addresses a regression introduced in PR #2056 that caused issues with filenames containing whitespace. The regular expression used to validate citation filenames has been updated to allow internal whitespace, ensuring proper handling of such filenames.

Does this introduce a breaking change?

When developers merge from main and run the server, azd up, or azd deploy, will this produce an error?
If you're not sure, try it out on an old environment.

[ ] Yes
[x] No

Does this require changes to learn.microsoft.com docs?

This repository is referenced by this tutorial
which includes deployment, settings and usage instructions. If text or screenshot need to change in the tutorial,
check the box below and notify the tutorial author. A Microsoft employee can do this for you if you're an external contributor.

[ ] Yes
[x] No

Type of change

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:

Code quality checklist

See CONTRIBUTING.md for more details.

  • The current tests all pass (python -m pytest).
  • I added tests that prove my fix is effective or that my feature works
  • I ran python -m pytest --cov to verify 100% coverage of added lines
  • I ran python -m mypy to check for type errors
  • I either used the pre-commit hooks or ran ruff and black manually on my code.

// Function to validate citation format and check if dataPoint starts with possible citation
function isCitationValid(contextDataPoints: any, citationCandidate: string): boolean {
const regex = /^[^\s]+\.[a-zA-Z0-9]+/;
const regex = /.+\.\w{1,}(?:#\S*)?$/;
Copy link
Contributor Author

Choose a reason for hiding this comment

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


    // Regex to allow filenames with internal whitespace and a valid extension
    // .+          : Matches one or more of any character (including whitespace)
    // \.\w{1,}    : Matches a dot followed by one or more word characters (file extension)
    // (?:#\S*)?$  : Optionally matches a hash followed by zero or more non-whitespace characters until the end of the string

@pamelafox pamelafox merged commit 38f7772 into Azure-Samples:main Oct 31, 2024
10 checks passed
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.

3 participants