Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion tv4.js
Original file line number Diff line number Diff line change
Expand Up @@ -1274,11 +1274,24 @@ ValidatorContext.prototype.validateHypermedia = function validateCombinations(da
}
};

// trim trailing whitespace
function trimRight(str){
if (str.trimRight) return str.trimRight();

var whitespace_pattern = /\s/,
i = str.length;
while (whitespace_pattern.test(str.charAt(--i)));

return str.slice(0, i + 1);
}



// parseURI() and resolveUrl() are from https://gist.github.com/1088850
// - released as public domain by author ("Yaffle") - see comments on gist

function parseURI(url) {
var m = String(url).replace(/^\s+|\s+$/g, '').match(/^([^:\/?#]+:)?(\/\/(?:[^:@]*(?::[^:@]*)?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);
var m = trimRight(String(url).replace(/^\s+/g, '')).match(/^([^:\/?#]+:)?(\/\/(?:[^:@]*(?::[^:@]*)?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);
// authority = '//' + user + ':' + pass '@' + hostname + ':' port
return (m ? {
href : m[0] || '',
Expand Down