aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAjay Ramachandran <[email protected]>2019-08-10 19:51:08 -0400
committerAjay Ramachandran <[email protected]>2019-08-10 19:51:08 -0400
commitccafbf663c0cd3c3800a7fd70ece4b65a39a3cda (patch)
tree00f61035a9419930e1a8a110f271509a1e520c9d
parentb964d93ea948b94515a7a93dc573c5ab5a52be3c (diff)
downloadSponsorBlock-ccafbf663c0cd3c3800a7fd70ece4b65a39a3cda.tar.gz
SponsorBlock-ccafbf663c0cd3c3800a7fd70ece4b65a39a3cda.zip
Fixed typos.
Co-author worked on creating this url parser. Co-Authored-By: Giacomo Rossetto <[email protected]>
-rw-r--r--utils.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/utils.js b/utils.js
index 80b4a1f3..2134c1af 100644
--- a/utils.js
+++ b/utils.js
@@ -1,13 +1,15 @@
function getYouTubeVideoID(url) {
- try { // Attempt to parse url
+ //Attempt to parse url
+ try {
var obj = new URL(url);
} catch (e) {
console.error("[SB] Unable to parser URL");
return false
}
- if(!["www.youtube.com","www.youtube-nocookie.com"].includes(obj.host)) return false // Check if valid hostname
+ //Check if valid hostname
+ if(!["www.youtube.com","www.youtube-nocookie.com"].includes(obj.host)) return false;
if (obj.pathname == "/watch" && obj.searchParams.has("v")) {
id = obj.searchParams.get("v"); // Get ID from searchParam
@@ -17,7 +19,7 @@ function getYouTubeVideoID(url) {
return obj.pathname.substr(7, 11);
} catch (e) {
console.error("[SB] Video ID not valid");
- return false
+ return false;
}
}
}