Skip to content

fix: download site bundle correctly if site name has special chars #232

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

Closed
wants to merge 5 commits into from

Conversation

pulkit0555
Copy link
Contributor

@pulkit0555 pulkit0555 commented Oct 31, 2024

What does this PR do?

Fixes the bug when site name contains special chars and we need to download site bundle

What issues does this PR fix or reference?

@W-16552899@

@pulkit0555 pulkit0555 self-assigned this Oct 31, 2024
Copy link

salesforce-cla bot commented Nov 3, 2024

Thanks for the contribution! Unfortunately we can't verify the commit author(s): pulkit.jain <p***@s***.com>. One possible solution is to add that email to your GitHub account. Alternatively you can change your commits to another email and force push the change. After getting your commits associated with your GitHub account, refresh the status of this Pull Request.

@pulkit0555 pulkit0555 changed the title fix: download site bundle correctly if site name has special chars @W-16552899 fix: download site bundle correctly if site name has special chars Nov 3, 2024
@pulkit0555 pulkit0555 changed the title @W-16552899 fix: download site bundle correctly if site name has special chars fix: download site bundle correctly if site name has special chars Nov 3, 2024
const result = await this.org
.getConnection()
.query<{ Name: string; LastModifiedDate: string }>(
`SELECT Name, LastModifiedDate FROM StaticResource WHERE Name LIKE 'MRT_experience_%_${this.siteName}'`
);
// Changing the site name back to original after fetching data from StaticResource so it may not break the flow elsewhere
// this.siteName = originalSiteName;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nrkruk If we uncomment this, it breaks the flow when we try to bring the site up in some cases where site name have special chars other than "-"

Copy link
Collaborator

@nrkruk nrkruk Nov 7, 2024

Choose a reason for hiding this comment

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

Not sure what this means. Does this impact functionality in some way? If we don't set this what happens?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nrkruk I was resetting the site name back to original after executing the query but when it tries to bring up the site it fails. So, basically we will get that site bundle but it won't bring up the site.

Also, should we do the site name updation inside the constructor itself? It's already replacing the space with underscore character.

  public constructor(org: Org, siteName: string) {
    this.org = org;
    this.siteDisplayName = siteName.trim();
    this.siteName = this.siteDisplayName.replace(' ', '_');
  }


export function replaceSpacesAndSpecialChars(value: string): string {
// Replace any special characters with underscore
value = value.replace(/[^a-zA-Z0-9]/g, '_');
Copy link
Collaborator

@nrkruk nrkruk Nov 7, 2024

Choose a reason for hiding this comment

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

so all special characters are always replaced with underscore? (I haven't tested this, but I assume you have)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have tested with below examples of site names, works fine.

  • space separated site
  • site@with#special-chars
  • site-with-hyphen
  • byoNoBasePath
  • byo enhanced

@nrkruk
Copy link
Collaborator

nrkruk commented Nov 7, 2024

We will also need to backport this to the 252-patch branch

@nrkruk nrkruk marked this pull request as ready for review November 18, 2024 21:59
@nrkruk nrkruk requested a review from a team as a code owner November 18, 2024 22:00
@pulkit0555
Copy link
Contributor Author

Closing this forked repo PR. Will create a new one.

@pulkit0555 pulkit0555 closed this Nov 20, 2024
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.

2 participants