Skip to content
This repository was archived by the owner on Jan 16, 2022. It is now read-only.

fix: generate correct registry URL#413

Merged
juanpicado merged 2 commits intoverdaccio:masterfrom
DanielRuf:fix/registry-url
Jan 9, 2020
Merged

fix: generate correct registry URL#413
juanpicado merged 2 commits intoverdaccio:masterfrom
DanielRuf:fix/registry-url

Conversation

@DanielRuf
Copy link
Copy Markdown
Contributor

Type:
bug

The following has been addressed in the PR:

  • There is a related issue? Yes
  • Unit or Functional tests are included in the PR? Yes

Description:
This PR correctly transforms /in the devmode to a full URL like in production and generates the correct registry URL.

Important: update combineBaseUrl in node_modules/verdaccio/build/lib/utils.js to the result of verdaccio/verdaccio#1647

function combineBaseUrl(protocol, host, prefix) {
  const result = `${protocol}://${host}`;

  const prefixOnlySlash = prefix === '/';
  if (prefix && !prefixOnlySlash) {
    if (prefix.endsWith('/')) {
      prefix = prefix.slice(0, -1);
    }

    if (prefix.startsWith('/')) {
      return `${result}${prefix}`;
    }

    return prefix;
  }

  return result;
}

Resolves verdaccio/verdaccio#1648

@DanielRuf DanielRuf requested review from a team January 8, 2020 21:24
@DanielRuf DanielRuf changed the title fix: generate correct registry url fix: generate correct registry URL Jan 8, 2020
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Jan 8, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 8, 2020

Codecov Report

Merging #413 into master will not change coverage.
The diff coverage is 100%.

@@           Coverage Diff           @@
##           master     #413   +/-   ##
=======================================
  Coverage   88.38%   88.38%           
=======================================
  Files         137      137           
  Lines         956      956           
  Branches      211      197   -14     
=======================================
  Hits          845      845           
- Misses         98       99    +1     
+ Partials       13       12    -1
Impacted Files Coverage Δ
src/utils/url.ts 20% <100%> (ø) ⬆️
src/components/Icon/styles.ts 88.88% <0%> (ø) ⬆️

@DanielRuf
Copy link
Copy Markdown
Contributor Author

Please run yarn build && yarn test:e2e when reviewing / testing.

test('getRegistryURL() - should not change when location change', () => {
expect(getRegistryURL()).toBe('http://localhost');
history.pushState({}, 'page title', '/-/web/detail');
expect(getRegistryURL()).toBe('http://localhost/-/web/detail');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good one

Copy link
Copy Markdown
Member

@juanpicado juanpicado left a comment

Choose a reason for hiding this comment

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

Thanks @DanielRuf now looks much better.

@DanielRuf
Copy link
Copy Markdown
Contributor Author

@juanpicado keep in mind that we might need the fix from verdaccio itself too (regarding verdaccio/verdaccio#1647)

@DanielRuf DanielRuf deleted the fix/registry-url branch January 9, 2020 05:24
@juanpicado
Copy link
Copy Markdown
Member

@DanielRuf do you mean update here the verdaccio dep right?

@DanielRuf
Copy link
Copy Markdown
Contributor Author

Exactly. But I see now that this is not released. It's just covering specific use cases.

https://github.com/verdaccio/verdaccio/commits/master

So I guess it is safe to ship the current changes without updating the deps.

@juanpicado
Copy link
Copy Markdown
Member

It will be on Friday. I just need to close one PR and we are done :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect npm/pnpm/yarn register info when viewed from a package

2 participants