MCPcopy Create free account
hub / github.com/ember-learn/ember-api-docs / findEndingRoute

Function findEndingRoute

app/controllers/project-version.js:143–159  ·  view source on GitHub ↗
({
  project,
  targetVersion,
  currentVersion,
  currentUrlVersion,
  currentURL,
  currentAnchor,
})

Source from the content-addressed store, hash-verified

141}
142
143export function findEndingRoute({
144 project,
145 targetVersion,
146 currentVersion,
147 currentUrlVersion,
148 currentURL,
149 currentAnchor,
150}) {
151 let projectVersionID = getCompactVersion(targetVersion);
152 // if the user is navigating to/from api versions Ember >= 2.16 or Ember Data >= 4.0, take them
153 // to the home page instead of trying to translate the url
154 if (shouldGoToVersionIndex(project, targetVersion, currentVersion)) {
155 return `/${project}/${projectVersionID}`;
156 } else {
157 return `${currentURL.replace(currentUrlVersion, projectVersionID)}${currentAnchor}`;
158 }
159}
160
161function shouldGoToVersionIndex(project, targetVersion, currentVersion) {
162 let boundaryVersion;

Callers 2

updateProjectMethod · 0.85

Calls 2

getCompactVersionFunction · 0.85
shouldGoToVersionIndexFunction · 0.85

Tested by

no test coverage detected