Home Reference Source
public class | source

WombatRewriter

The base Wombat Class, responsible for rewrites

Member Summary

Public Members
public

The window object associated with iframe[id="replay_iframe"]

public

An array of bad prefixes, use WombatRewriter#init_bad_prefixes to initialize it

public

Array of HTML tag names that have the src attribute

 ["LINK", "A"]
public

https://

public

http://

public

Array of prefixes to be ignored

 ["#", "about:", "data:", "mailto:", "javascript:", "{", "*"]
public

The regular expression to rewrite a cookies IP address

public

//

public

Array of HTML tag names that have contain attributes to be rewritten

 ["src", "href", "poster"]
public

Array of HTML tag names that have the src attribute

 ["IFRAME", "IMG", "SCRIPT", "VIDEO", "AUDIO", "SOURCE", "EMBED", "INPUT"]
public

The style parsing regular expression used when rewriting style attributes

public

Array of URL property names

 ["href", "hash", "pathname", "host", "hostname", "protocol", "origin", "search", "port"]
public

Array of valid prefixes

public

The regular expression to rewrite a cookies domain

public

The regular expression to rewrite a cookies expires

public

The regular expression to rewrite a cookies path

public
public
public
public

wb_getAttribute: Element.prototype.function

public

wb_info: {is_live: boolean, wombat_ts: string, mod: string}

Wombat information concerning replay

public
public

Custom options

public
public
public
public
public
public

wb_setAttribute: Element.prototype.function

public

Is wb_wombat updating

public

buffered used by {WombatRewriter#rewrite_html}

Method Summary

Public Methods
public

Extract the origin from a given href

public

get_final_url(prefix: string, mod: string, url: string): string

Apply the wb_info.mod and appropriate prefix to the url

public

Initialize the BAD_PREFIXES array with the given prefix

public

init_paths(wbinfo: {?wombat_opts: Object, prefix: string, wombat_scheme: string, top_host: string, ?proxy_magic: string|boolean, wombat_host: string, is_live: boolean, wombat_ts: string, is_framed: boolean})

Initialize Wombat metadata about replay or proxy

public

Create a parser element

public

Resolve the given relative url

public

rewrite_attr(elem: DomElement, name: string, abs_url_only: boolean): boolean | undefined

Rewrite the attribute of a given element

public

Request a blob and remove __WB_pmw rewrites that may have been made to the blobs contents

public

Rewrite a cookie

  • the path to the original path not the replay path
  • the domain to the original domain not the replay domain
public
public

Rewrite a frames src attribute

public

rewrite_html(string: string, check_end_tag: boolean): string

Rewrite a string containing HTML markup

public

Rewrite a srcset value

public

rewrite the value of a style tag

public

rewrite_url_debug(url: string, use_rel: boolean, mod: string): string

debug version of WombatRewriter#rewriteurl

Private Methods
private

Rewrites the cookies domain

private

Rewrite a cookies path

private

Rewrite the expires datetime of cookie when set

private

rewrite_url_(url: string, use_rel: boolean, mod: string): string

Rewrite the given url

Public Members

public $wbwindow: Window source

The window object associated with iframe[id="replay_iframe"]

public BAD_PREFIXES: string[] | undefined source

An array of bad prefixes, use WombatRewriter#init_bad_prefixes to initialize it

public HREF_TAGS: string[] source

Array of HTML tag names that have the src attribute

 ["LINK", "A"]

public HTTPS_PREFIX: string source

https://

public HTTP_PREFIX: string source

http://

public IGNORE_PREFIXES: string[] source

Array of prefixes to be ignored

 ["#", "about:", "data:", "mailto:", "javascript:", "{", "*"]

public IP_RX: RegExp source

The regular expression to rewrite a cookies IP address

public REL_PREFIX: string source

//

public REWRITE_ATTRS: string[] source

Array of HTML tag names that have contain attributes to be rewritten

 ["src", "href", "poster"]

public SRC_TAGS: string[] source

Array of HTML tag names that have the src attribute

 ["IFRAME", "IMG", "SCRIPT", "VIDEO", "AUDIO", "SOURCE", "EMBED", "INPUT"]

public STYLE_REGEX: RegExp source

The style parsing regular expression used when rewriting style attributes

public URL_PROPS: string[] source

Array of URL property names

 ["href", "hash", "pathname", "host", "hostname", "protocol", "origin", "search", "port"]

public VALID_PREFIXES: string[] source

Array of valid prefixes

The regular expression to rewrite a cookies domain

The regular expression to rewrite a cookies expires

The regular expression to rewrite a cookies path

public wb_abs_prefix: string source

public wb_capture_date_part: string source

public wb_curr_host: string source

public wb_getAttribute: Element.prototype.function source

public wb_info: {is_live: boolean, wombat_ts: string, mod: string} source

Wombat information concerning replay

public wb_is_proxy: boolean source

public wb_opts: Object source

Custom options

public wb_orig_origin: string source

public wb_orig_scheme: string source

public wb_rel_prefix: string source

public wb_rel_prefix_check: string source

public wb_replay_prefix: string source

public wb_setAttribute: Element.prototype.function source

public wb_wombat_updating: boolean source

Is wb_wombat updating

public write_buff: string source

buffered used by {WombatRewriter#rewrite_html}

Public Methods

public extract_orig(href: string): string source

Extract the origin from a given href

Params:

NameTypeAttributeDescription
href string

the href to extract the origin from

Return:

string

returns the origin href if the href is defined otherwise returns an empty string

public get_final_url(prefix: string, mod: string, url: string): string source

Apply the wb_info.mod and appropriate prefix to the url

Params:

NameTypeAttributeDescription
prefix string

the prefix to add to the url

mod string

the modifier to add to the url

url string

the url to add the final touches to

Return:

string

returns the final url

public init_bad_prefixes(prefix: string) source

Initialize the BAD_PREFIXES array with the given prefix

Params:

NameTypeAttributeDescription
prefix string

the bad prefix

public init_paths(wbinfo: {?wombat_opts: Object, prefix: string, wombat_scheme: string, top_host: string, ?proxy_magic: string|boolean, wombat_host: string, is_live: boolean, wombat_ts: string, is_framed: boolean}) source

Initialize Wombat metadata about replay or proxy

Params:

NameTypeAttributeDescription
wbinfo {?wombat_opts: Object, prefix: string, wombat_scheme: string, top_host: string, ?proxy_magic: string|boolean, wombat_host: string, is_live: boolean, wombat_ts: string, is_framed: boolean}

public make_parser(href: string): Element source

Create a parser element

Params:

NameTypeAttributeDescription
href string

the href of the parser element

Return:

Element

the parser element (A tag)

public resolve_rel_url(url: string): string source

Resolve the given relative url

Params:

NameTypeAttributeDescription
url string

the relative url to resolve

Return:

string

the resolved url

public rewrite_attr(elem: DomElement, name: string, abs_url_only: boolean): boolean | undefined source

Rewrite the attribute of a given element

Params:

NameTypeAttributeDescription
elem DomElement

the element who's attribute is to be rewritten

name string

the name of the attribute to be rewritten

abs_url_only boolean

if the attribute of the element tobe rewritten is for instance href set to true if the rewrite is to be made if the original value of the attribute is an absolute url

Return:

boolean | undefined

returns true if the rewrite was made otherwise undefined

public rewrite_blob(url: string): string source

Request a blob and remove __WB_pmw rewrites that may have been made to the blobs contents

Params:

NameTypeAttributeDescription
url string

the URL of the blob

Return:

string

Rewrite a cookie

  • the path to the original path not the replay path
  • the domain to the original domain not the replay domain

Params:

NameTypeAttributeDescription
cookie string

the cookie to be rewritten

Return:

string

the rewritten cookie

public rewrite_elem(elem: DomElement): boolean source

Rewrite a DOM Element WombatRewriter#rewrite_style WombatRewriter#rewrite_frame_src WombatRewriter#rewrite_attr

Params:

NameTypeAttributeDescription
elem DomElement

the element to rewrite

Return:

boolean (nullable: true)

returns true or false depending on if the element being rewritten changed returns undefined if the element is null or undefined

public rewrite_frame_src(elem: DomElement, name: string): boolean source

Rewrite a frames src attribute

Params:

NameTypeAttributeDescription
elem DomElement

the frame element whoes src attribute to rewrite

name string

the name of the property to rewrite

Return:

boolean

returns true if the rewrite was made otherwise false

public rewrite_html(string: string, check_end_tag: boolean): string source

Rewrite a string containing HTML markup

Params:

NameTypeAttributeDescription
string string

the string containing HTML markup

check_end_tag boolean

check for end tag alignment of the rewritten html string

Return:

string

public rewrite_srcset(value: string): string source

Rewrite a srcset value

Params:

NameTypeAttributeDescription
value string

Return:

string

the rewritten srcset value

public rewrite_style(value: string): string source

rewrite the value of a style tag

Params:

NameTypeAttributeDescription
value string

Return:

string

public rewrite_url_debug(url: string, use_rel: boolean, mod: string): string source

debug version of WombatRewriter#rewriteurl

Params:

NameTypeAttributeDescription
url string
use_rel boolean
mod string

Return:

string (nullable: true)

Private Methods

private _rewriteCookieDomain(cookie: string, m: string, m1: string): string source

Rewrites the cookies domain

Params:

NameTypeAttributeDescription
cookie string

the cookie currently being rewritten

m string

the matched substring

m1 string

the first parenthesized submatch string

Return:

string

the cookies rewritten domain

private _rewriteCookiePath(m: string, m1: string): string source

Rewrite a cookies path

Params:

NameTypeAttributeDescription
m string

the matched substring

m1 string

the first parenthesized submatch string

Return:

string

the cookies rewritten path

private _setCookieExpiresRewrite(m: string, d1: string): string source

Rewrite the expires datetime of cookie when set

Params:

NameTypeAttributeDescription
m string

the matched substring

d1 string

the first parenthesized submatch string

Return:

string

the cookies rewritten path

private rewrite_url_(url: string, use_rel: boolean, mod: string): string source

Rewrite the given url

Params:

NameTypeAttributeDescription
url string
use_rel boolean
mod string

Return:

string (nullable: true)

if the url to be rewritten is undefined or null returns the original value

  • if the url is not a string or an object that results in an url after calling toString return the original value
  • if the url starts with an ignored prefix return the original value
  • if wb_is_proxy and the scheme can not be rewritten return the original value
  • otherwise returns the rewritten url