diff --git a/NzbDrone.Host/Owin/OwinHostController.cs b/NzbDrone.Host/Owin/OwinHostController.cs index 8eabe82b5..c11c0f99d 100644 --- a/NzbDrone.Host/Owin/OwinHostController.cs +++ b/NzbDrone.Host/Owin/OwinHostController.cs @@ -60,17 +60,18 @@ namespace NzbDrone.Host.Owin { if (ex.InnerException == null) { - throw ex; + throw; } - if (ex.InnerException as HttpListenerException == null) + if (ex.InnerException is HttpListenerException) { - throw ex; + throw new PortInUseException("Port {0} is already in use, please ensure NzbDrone is not already running.", + ex, + _configFileProvider.Port); } - throw new PortInUseException("Port {0} is already in use, please ensure NzbDrone is not already running.", - ex, - _configFileProvider.Port); + throw ex.InnerException; + } } diff --git a/UI/Handlebars/Helpers/Series.js b/UI/Handlebars/Helpers/Series.js index fe9b3fa89..f9d849325 100644 --- a/UI/Handlebars/Helpers/Series.js +++ b/UI/Handlebars/Helpers/Series.js @@ -64,7 +64,7 @@ define( }); Handlebars.registerHelper('titleWithYear', function () { - if (this.title.match(/\s\(\d{4}\)$/)) { + if (this.title.endsWith(' ({0})'.format(this.year))) { return this.title; } diff --git a/UI/Mixins/backbone.ajax.js b/UI/Mixins/backbone.ajax.js index 5bfbe6d13..0544b2e28 100644 --- a/UI/Mixins/backbone.ajax.js +++ b/UI/Mixins/backbone.ajax.js @@ -11,7 +11,7 @@ define(function () { //check if ajax call was made with data option if (xhr && xhr.data && xhr.type === 'DELETE') { - if (xhr.url.indexOf('?') === -1) { + if (!xhr.url.contains('?')) { xhr.url = xhr.url + '?' + $.param(xhr.data); } else { diff --git a/UI/Shared/StringHelpers.js b/UI/Shared/StringHelpers.js deleted file mode 100644 index e5fafb55a..000000000 --- a/UI/Shared/StringHelpers.js +++ /dev/null @@ -1,33 +0,0 @@ -'use strict'; - -define( - [ - ], function () { - - return { - - startsWith: function (str, starts) { - if (starts === '') { - return true; - } - if (str == null || starts == null) { - return false; - } - str = String(str); - starts = String(starts); - return str.length >= starts.length && str.slice(0, starts.length) === starts; - }, - - endsWith: function (str, ends) { - if (ends === '') { - return true; - } - if (str == null || ends == null) { - return false; - } - str = String(str); - ends = String(ends); - return str.length >= ends.length && str.slice(str.length - ends.length) === ends; - } - } - }); diff --git a/UI/index.html b/UI/index.html index 5a4659fa5..5ffff693e 100644 --- a/UI/index.html +++ b/UI/index.html @@ -60,6 +60,7 @@ + diff --git a/UI/jQuery/RouteBinder.js b/UI/jQuery/RouteBinder.js index 7b599cc88..70ffc8742 100644 --- a/UI/jQuery/RouteBinder.js +++ b/UI/jQuery/RouteBinder.js @@ -1,5 +1,5 @@ 'use strict'; -define(['Shared/StringHelpers'],function (StringHelpers) { +define(function () { //This module will automatically route all relative links through backbone router rather than //causing links to reload pages. @@ -40,7 +40,7 @@ define(['Shared/StringHelpers'],function (StringHelpers) { } - if (!StringHelpers.startsWith(href, 'http')) { + if (!href.startsWith('http')) { router.navigate(href, { trigger: true }); } diff --git a/UI/polyfills.js b/UI/polyfills.js new file mode 100644 index 000000000..3e6797bf8 --- /dev/null +++ b/UI/polyfills.js @@ -0,0 +1,32 @@ +if (!String.prototype.startsWith) { + Object.defineProperty(String.prototype, 'startsWith', { + enumerable: false, + configurable: false, + writable: false, + value: function (searchString, position) { + position = position || 0; + return this.indexOf(searchString, position) === position; + } + }); +} + +if (!String.prototype.endsWith) { + Object.defineProperty(String.prototype, 'endsWith', { + enumerable: false, + configurable: false, + writable: false, + value: function (searchString, position) { + position = position || this.length; + position = position - searchString.length; + var lastIndex = this.lastIndexOf(searchString); + return lastIndex !== -1 && lastIndex === position; + } + }); +} + +if(!('contains' in String.prototype)) +{ + String.prototype.contains = function(str, startIndex) { + return -1 !== String.prototype.indexOf.call(this, str, startIndex); + }; +} \ No newline at end of file