Skip to content

Commit

Permalink
enforcing better URL formatting for Site URL setting.
Browse files Browse the repository at this point in the history
  • Loading branch information
SachaG committed Jun 5, 2015
1 parent b3aa6d0 commit bc77ce6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Just a couple minor bug fixes.
* Generate public user properties list from schema.
* Fixed video lightbox issue.
* Updated Getting Started content.
* Enforcing better URL formatting for Site URL setting.

## v0.20.4 “RefactorScope”

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@ AutoForm.addInputType("bootstrap-url", {
template: "afBootstrapUrl",
valueOut: function () {
var url = this.val();
if(!!url)
return (url.substring(0, 7) === "http://" || url.substring(0, 8) === "https://") ? url : "http://"+url;
if (!!url) {
// add http:// if missing
if (url.substring(0, 7) !== "http://" && url.substring(0, 8) !== "https://") {
url = "http://"+url;
}
// add trailing / if missing (unless URL contains a "?")
if (url.slice(-1) !== "/" && url.indexOf("?") === -1) {
url = url + "/";
}
return url;
}
}
});

Expand Down
3 changes: 2 additions & 1 deletion packages/telescope-releases/releases/0.20.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ Just a couple minor bug fixes.
* Improve profile completion screen validation & errors.
* Generate public user properties list from schema.
* Fixed video lightbox issue.
* Updated Getting Started content.
* Updated Getting Started content.
* Enforcing better URL formatting for Site URL setting.
3 changes: 2 additions & 1 deletion packages/telescope-settings/lib/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ Settings.schema = new SimpleSchema({
siteUrl: {
type: String,
optional: true,
regEx: SimpleSchema.RegEx.Url,
// regEx: SimpleSchema.RegEx.Url,
autoform: {
group: "01_general",
type: "bootstrap-url",
instructions: 'Your site\'s URL (with trailing "/"). Will default to Meteor.absoluteUrl()'
}
},
Expand Down

0 comments on commit bc77ce6

Please sign in to comment.