Github user millayr commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/862#discussion_r102474542
  
    --- Diff: app/addons/replication/api.js ---
    @@ -41,6 +42,38 @@ export const getAuthHeaders = (username, password) => {
       };
     };
     
    +export const getCredentialsFromUrl = (url) => {
    +  const index = url.lastIndexOf('@');
    +  if (index === -1) {
    +    return {
    +      username: '',
    +      password: ''
    +    };
    +  }
    +
    +  const startIndex = url.startsWith("https") ? 8 : 7;
    +  const rawCreds = url.slice(startIndex, index);
    +  const colonIndex = rawCreds.indexOf(':');
    +  const username = rawCreds.slice(0, colonIndex);
    +  const password = rawCreds.slice(colonIndex + 1, rawCreds.length);
    --- End diff --
    
    Minor note but I think you could combine all of these variable 
instantiations and assignments in to a single const statement.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to