Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion build/tincan-min.js

Large diffs are not rendered by default.

60 changes: 54 additions & 6 deletions build/tincan.js
Original file line number Diff line number Diff line change
Expand Up @@ -1552,11 +1552,18 @@ TinCan client library
schemeMatches,
locationPort,
isXD,
env = TinCan.environment()
env = TinCan.environment(),
versions = TinCan.versions(),
versionMatch = false,
i
;

cfg = cfg || {};

if (cfg.hasOwnProperty("alertOnRequestFailure")) {
this.alertOnRequestFailure = cfg.alertOnRequestFailure;
}

if (! cfg.hasOwnProperty("endpoint")) {
if (env.isBrowser && this.alertOnRequestFailure) {
alert("[error] LRS invalid: no endpoint");
Expand All @@ -1568,6 +1575,10 @@ TinCan client library
}

this.endpoint = cfg.endpoint;
if (this.endpoint.slice(-1) !== "/") {
this.log("adding trailing slash to endpoint");
this.endpoint += "/";
}

if (cfg.hasOwnProperty("allowFail")) {
this.allowFail = cfg.allowFail;
Expand All @@ -1584,9 +1595,18 @@ TinCan client library
this.extended = cfg.extended;
}

urlParts = cfg.endpoint.toLowerCase().match(/([A-Za-z]+:)\/\/([^:\/]+):?(\d+)?(\/.*)?$/);

if (env.isBrowser) {
urlParts = this.endpoint.toLowerCase().match(/([A-Za-z]+:)\/\/([^:\/]+):?(\d+)?(\/.*)?$/);
if (urlParts === null) {
if (this.alertOnRequestFailure) {
alert("[error] LRS invalid: failed to divide URL parts");
}
throw {
code: 4,
mesg: "LRS invalid: failed to divide URL parts"
};
}

//
// determine whether this is a cross domain request,
// whether our browser has CORS support at all, and then
Expand Down Expand Up @@ -1650,7 +1670,7 @@ TinCan client library
alert("[error] LRS invalid: cross domain requests not supported in this browser");
}
throw {
code: 2,
code: 1,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these codes documented somewhere? If not whats the point other than just using the error message?

mesg: "LRS invalid: cross domain requests not supported in this browser"
};
}
Expand All @@ -1663,14 +1683,29 @@ TinCan client library

if (typeof cfg.version !== "undefined") {
this.log("version: " + cfg.version);
for (i = 0; i < versions.length; i += 1) {
if (versions[i] === cfg.version) {
versionMatch = true;
break;
}
}
if (! versionMatch) {
if (env.isBrowser && this.alertOnRequestFailure) {
alert("[error] LRS invalid: version not supported (" + cfg.version + ")");
}
throw {
code: 5,
mesg: "LRS invalid: version not supported (" + cfg.version + ")"
};
}
this.version = cfg.version;
}
else {
//
// assume max supported when not specified,
// TODO: add detection of LRS from call to endpoint
//
this.version = TinCan.versions()[0];
this.version = versions[0];
}
},

Expand Down Expand Up @@ -4160,6 +4195,12 @@ TinCan client library
*/
this.type = null;

/**
@property moreInfo
@type String
*/
this.moreInfo = null;

/**
@property extensions
@type Object
Expand Down Expand Up @@ -4214,7 +4255,7 @@ TinCan client library
/**
@property LOG_SRC
*/
LOG_SRC: 'ActivityDefinition',
LOG_SRC: "ActivityDefinition",

/**
@method log
Expand All @@ -4234,6 +4275,7 @@ TinCan client library
directProps = [
"name",
"description",
"moreInfo",
"extensions",
"correctResponsesPattern"
],
Expand Down Expand Up @@ -4371,6 +4413,12 @@ TinCan client library
}
}

if (version.indexOf("0.9") !== 0) {
if (this.moreInfo !== null) {
result.moreInfo = this.moreInfo;
}
}

return result;
},

Expand Down
15 changes: 14 additions & 1 deletion src/ActivityDefinition.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ TinCan client library
*/
this.type = null;

/**
@property moreInfo
@type String
*/
this.moreInfo = null;

/**
@property extensions
@type Object
Expand Down Expand Up @@ -127,7 +133,7 @@ TinCan client library
/**
@property LOG_SRC
*/
LOG_SRC: 'ActivityDefinition',
LOG_SRC: "ActivityDefinition",

/**
@method log
Expand All @@ -147,6 +153,7 @@ TinCan client library
directProps = [
"name",
"description",
"moreInfo",
"extensions",
"correctResponsesPattern"
],
Expand Down Expand Up @@ -284,6 +291,12 @@ TinCan client library
}
}

if (version.indexOf("0.9") !== 0) {
if (this.moreInfo !== null) {
result.moreInfo = this.moreInfo;
}
}

return result;
},

Expand Down
45 changes: 40 additions & 5 deletions src/LRS.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,18 @@ TinCan client library
schemeMatches,
locationPort,
isXD,
env = TinCan.environment()
env = TinCan.environment(),
versions = TinCan.versions(),
versionMatch = false,
i
;

cfg = cfg || {};

if (cfg.hasOwnProperty("alertOnRequestFailure")) {
this.alertOnRequestFailure = cfg.alertOnRequestFailure;
}

if (! cfg.hasOwnProperty("endpoint")) {
if (env.isBrowser && this.alertOnRequestFailure) {
alert("[error] LRS invalid: no endpoint");
Expand All @@ -118,6 +125,10 @@ TinCan client library
}

this.endpoint = cfg.endpoint;
if (this.endpoint.slice(-1) !== "/") {
this.log("adding trailing slash to endpoint");
this.endpoint += "/";
}

if (cfg.hasOwnProperty("allowFail")) {
this.allowFail = cfg.allowFail;
Expand All @@ -134,9 +145,18 @@ TinCan client library
this.extended = cfg.extended;
}

urlParts = cfg.endpoint.toLowerCase().match(/([A-Za-z]+:)\/\/([^:\/]+):?(\d+)?(\/.*)?$/);

if (env.isBrowser) {
urlParts = this.endpoint.toLowerCase().match(/([A-Za-z]+:)\/\/([^:\/]+):?(\d+)?(\/.*)?$/);
if (urlParts === null) {
if (this.alertOnRequestFailure) {
alert("[error] LRS invalid: failed to divide URL parts");
}
throw {
code: 4,
mesg: "LRS invalid: failed to divide URL parts"
};
}

//
// determine whether this is a cross domain request,
// whether our browser has CORS support at all, and then
Expand Down Expand Up @@ -200,7 +220,7 @@ TinCan client library
alert("[error] LRS invalid: cross domain requests not supported in this browser");
}
throw {
code: 2,
code: 1,
mesg: "LRS invalid: cross domain requests not supported in this browser"
};
}
Expand All @@ -213,14 +233,29 @@ TinCan client library

if (typeof cfg.version !== "undefined") {
this.log("version: " + cfg.version);
for (i = 0; i < versions.length; i += 1) {
if (versions[i] === cfg.version) {
versionMatch = true;
break;
}
}
if (! versionMatch) {
if (env.isBrowser && this.alertOnRequestFailure) {
alert("[error] LRS invalid: version not supported (" + cfg.version + ")");
}
throw {
code: 5,
mesg: "LRS invalid: version not supported (" + cfg.version + ")"
};
}
this.version = cfg.version;
}
else {
//
// assume max supported when not specified,
// TODO: add detection of LRS from call to endpoint
//
this.version = TinCan.versions()[0];
this.version = versions[0];
}
},

Expand Down
Loading