Skip to content

Instantly share code, notes, and snippets.

@jgphilpott
Last active September 13, 2023 14:00
Show Gist options
  • Save jgphilpott/68e9e22ea6ac5bf44ff7a86ef75b5e5d to your computer and use it in GitHub Desktop.
Save jgphilpott/68e9e22ea6ac5bf44ff7a86ef75b5e5d to your computer and use it in GitHub Desktop.

Revisions

  1. jgphilpott revised this gist Sep 13, 2023. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions page.js
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,7 @@
    var Page;

    Page = class Page {

    constructor() {
    this.url = window.location;
    }
  2. jgphilpott created this gist Sep 13, 2023.
    31 changes: 31 additions & 0 deletions page.coffee
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    # Credit: https://www.w3schools.com/js/js_window_location.asp

    class Page

    constructor: ->

    @url = window.location

    href: ->

    return this.url.href

    protocol: ->

    return this.url.protocol

    host: ->

    return this.url.hostname

    path: ->

    return this.url.pathname

    port: ->

    return this.url.port

    redirect: (href = "") ->

    return this.url.assign href
    34 changes: 34 additions & 0 deletions page.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    // Credit: https://www.w3schools.com/js/js_window_location.asp

    var Page;

    Page = class Page {
    constructor() {
    this.url = window.location;
    }

    href() {
    return this.url.href;
    }

    protocol() {
    return this.url.protocol;
    }

    host() {
    return this.url.hostname;
    }

    path() {
    return this.url.pathname;
    }

    port() {
    return this.url.port;
    }

    redirect(href = "") {
    return this.url.assign(href);
    }

    };