1.3.7 • Published 4 years ago

find-next-version v1.3.7

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

find-next-version

find next version

status: production ready

<script src="/path/to/find-next-version.js" defer></script>
<script defer>
(function(info) {
  FindNextVersion.find({ from: info.version, url: FindNextVersion.url.index })
    .then(function(version) {
      location.href = "/" + version + "/" + info.path + location.search;
    });
})(FindNextVersion.parse_pathname(location.pathname));
</script>
Table of Contents

Requirements

  • Promise

Usage

Install

npm install find-next-version
cp node_modules/find-next-version/dist/find-next-version.js path/to/find-next-version.js

find

find next version

FindNextVersion.find({
  from: "0.0.0", // start finding from this version
  url: function(version) {
    // construct search url
    return "/" + version + "/index.html";
  },
}) // => Promise
  .then(function(version) {
    // next version found
  })
  .catch(function() {
    // next version not found
  });
  1. request to HEAD /1.0.1/index.html, HEAD /1.1.0/index.html, HEAD /2.0.0/index.html
  2. if response status is 200, re-check (1) with next version
  3. finally, resolve with (2) version

version number must follow semantic version rule

url

construct search url functions

FindNextVersion.url.index("1.0.0") // => "/1.0.0/index.html"

parse_pathname

get version and path from pathname

FindNextVersion.parse_pathname("/1.0.0/path/to/request")
// => { version: "1.0.0", path: "path/to/request" }

FindNextVersion.parse_pathname("/")
// => { version: "0.0.0", path: "" }

FindNextVersion.parse_pathname("/", {fallback_version: "2.0.0"})
// => { version: "2.0.0", path: "" }

License

find-next-version is licensed under the MIT license.

Copyright © since 2019 shun@getto.systems

1.3.7

4 years ago

1.3.6

4 years ago

1.3.5

4 years ago

1.3.4

4 years ago

1.3.3

4 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago

0.0.1

5 years ago