Skip to content

Commit

Permalink
Merge branch 'master' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
deepjyoti30 committed Feb 18, 2023
2 parents 0e362d3 + 4938203 commit 57f5970
Show file tree
Hide file tree
Showing 3 changed files with 11,361 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/SearchBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export default {
*/
// If the string is of the new type then extract it separately.
if (enteredUrl.includes("youtu.be")) {
return enteredUrl.replace("youtu.be/", "");
return enteredUrl.replace(/(https?:\/\/)?youtu.be\//g, "");
}
const urlParams = new URLSearchParams(
Expand Down
22 changes: 22 additions & 0 deletions tests/__tests__/searchBar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,26 @@ describe("Mounted SearchBar", () => {

expect(wrapper.vm.isYoutubeUrl).toBeTruthy();

wrapper.setData({
$route: {
query: {
query: "https://youtu.be/test"
}
}
});

expect(wrapper.vm.isYoutubeUrl).toBeTruthy();

wrapper.setData({
$route: {
query: {
query: "youtu.be/test"
}
}
});

expect(wrapper.vm.isYoutubeUrl).toBeTruthy();

wrapper.setData({
$route: {
query: {
Expand All @@ -61,6 +81,8 @@ describe("Mounted SearchBar", () => {
expect(wrapper.vm.extractVideoId("https://youtube.com/watch?v=test")).toBe(
"test"
);
expect(wrapper.vm.extractVideoId("https://youtu.be/test")).toBe("test");
expect(wrapper.vm.extractVideoId("youtu.be/test")).toBe("test");
});

it("should send search request for query", () => {
Expand Down
Loading

0 comments on commit 57f5970

Please sign in to comment.