0.1.0 • Published 6 years ago

getto-detect v0.1.0

Weekly downloads
10
License
MIT
Repository
github
Last release
6 years ago

getto-detect

javascript function for static web to detect next version's path

GettoDetect().from_current_version("1.0.0", function(path) {
  path // => "/2.1.0/index.html" (e.g.)

  // redirect to next version
  location.href = path
});
  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, callback with (2) path
  • version number must follow semantic version rule
Table of Contents

Usage

Install

npm install --save-dev getto-detect
cp node_modules/getto-detect/dist/getto-detect.js /path/to/your/project

or

curl https://github.com/getto-systems/getto-detect/blob/master/dist/getto-detect.js -o /path/to/your/project/getto-detect.js

from_current_version

GettoDetect().from_current_version(
  "1.0.0", // the version to start detecting
  function(path) {
    // detected
  },
  function() {
    // not found
  }
);

detect next version's path from current version

options

version_to_path

GettoDetect({
  // function that convert from version number to path
  version_to_path: function(version) {
    return "/" + version + "/index.html";
  },
})

specify function that convert from version number to path

License

getto-detect is licensed under the MIT license.

Copyright © since 2018 shun@getto.systems