INNER CODE UNIT · JavaScript

NewGistLocation

carvel-dev/ytt · pkg/website/js/app.js:331

function NewGistLocation() {
  var prefix = "#gist:";
  return {
    isSet: function() {
      return window.location.hash && window.location.hash.startsWith(prefix);
    },
    get: function() {
      var id = null;
      if (window.location.hash) {
        if (window.location.hash.startsWith(prefix)) {
          id = window.location.hash.replace(prefix, "", 1);
        }
      }
      // Gist URL looks like this: https://gist.github.com/cppforlife/ed41c0e8ab19029347732ba247a6c460
      if (id && id.startsWith("https://")) {
        id = id.split("/").slice(-1)[0];
      }
      return id

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…