Repository: spotify/backstage
File: packages/integration/src/azure/DefaultAzureDevOpsCredentialsProvider.ts (TypeScript)

Code before:
    if (url.host !== 'dev.azure.com' && parts.length > 0) {
      if (parts[0] !== 'tfs') {
        // url format: https://{host}/{organization}
        return this.providers.get(`${url.host}/${parts[0]}`);
      } else if (parts[0] === 'tfs' && parts.length > 1) {
        // url format: https://{host}/tfs/{organization}
        return this.providers.get(`${url.host}/${parts[1]}`);
      }
    }

    return undefined;
  }

  private forAzureDevOpsOrganization(
    url: URL,
  ): AzureDevOpsCredentialsProvider | undefined {
    const parts = url.pathname.split('/').filter(part => part !== '');
    if (url.host === 'dev.azure.com' && parts.length > 0) {
      // url format: https://{host}/{organization}
      return this.providers.get(`${url.host}/${parts[0]}`);
    }

    return undefined;
  }

  private forVisualstudioOrganization(
    url: URL,
  ): AzureDevOpsCredentialsProvider | undefined {
    const parts = url.host.split('.');
    if (url.host.includes('visualstudio.com') && parts.length > 0) {
      // url format: https://{organization}.visualstudio.com
      return this.providers.get(`${url.host}/${parts[0]}`);
    }

    return undefined;
  }

  private forHost(url: URL): AzureDevOpsCredentialsProvider | undefined {
    return this.providers.get(url.host);
  }

  async getCredentials(opts: {
    url: string;
  }): Promise<AzureDevOpsCredentials | undefined> {
    const url = new URL(opts.url);
    const provider =
      this.forAzureDevOpsOrganization(url) ??
      this.forAzureDevOpsServerOrganization(url) ??
      this.forVisualstudioOrganization(url) ??
      this.forHost(url);


Review comment (suggestion):
Microsoft uses "Visual Studio" I believe, in which case this should be an upper-case "S"
```suggestion
  private forVisualStudioOrganization(
```

Code after:
    const parts = url.pathname.split('/').filter(part => part !== '');
    if (url.host !== 'dev.azure.com' && parts.length > 0) {
      if (parts[0] !== 'tfs') {
        // url format: https://{host}/{organization}
        return this.providers.get(`${url.host}/${parts[0]}`);
      } else if (parts[0] === 'tfs' && parts.length > 1) {
        // url format: https://{host}/tfs/{organization}
        return this.providers.get(`${url.host}/${parts[1]}`);
      }
    }

    return undefined;
  }

  private forAzureDevOpsOrganization(
    url: URL,
  ): AzureDevOpsCredentialsProvider | undefined {
    const parts = url.pathname.split('/').filter(part => part !== '');
    if (url.host === 'dev.azure.com' && parts.length > 0) {
      // url format: https://{host}/{organization}
      return this.providers.get(`${url.host}/${parts[0]}`);
    }

    return undefined;
  }

  private forVisualStudioOrganization(
    url: URL,
  ): AzureDevOpsCredentialsProvider | undefined {
    const parts = url.host.split('.');
    if (isVisualStudioDomain(url.origin) && parts.length > 0) {
      return this.providers.get(url.host);
    }

    return undefined;
  }

  private forHost(url: URL): AzureDevOpsCredentialsProvider | undefined {
    return this.providers.get(url.host);
  }

  async getCredentials(opts: {
    url: string;
  }): Promise<AzureDevOpsCredentials | undefined> {
    const url = new URL(opts.url);
    const provider =
      this.forAzureDevOpsOrganization(url) ??
      this.forAzureDevOpsServerOrganization(url) ??
      this.forVisualStudioOrganization(url) ??
      this.forHost(url);