Skip to content

Commit

Permalink
v3.0.1
Browse files Browse the repository at this point in the history
- Added safety check to .title.toLowerCase so that it checks if `.title` is defined in order to provent possible null reference exception.
  • Loading branch information
DaniloNovakovic committed Jan 19, 2020
1 parent 77f2ca4 commit 03ac118
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chrome-dynamic-bookmarks",
"version": "3.0.0",
"version": "3.0.1",
"description": "Chrome extension which dynamically updates bookmarks based on the specified regular expression.",
"scripts": {
"start": "webpack-dev-server --open --env.env=dev",
Expand Down
40 changes: 23 additions & 17 deletions public/bookmarkManager.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="http://localhost:8097"></script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<!-- Fonts to support Material Design -->
<link type="text/css" rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
<!-- Icons to support Material Design -->
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
<head>
<!-- For developement-->
<!-- <script src="http://localhost:8097"></script> -->
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<!-- Fonts to support Material Design -->
<link
type="text/css"
rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"
/>
<!-- Icons to support Material Design -->
<link
rel="stylesheet"
href="https://fonts.googleapis.com/icon?family=Material+Icons"
/>

<title>Dynamic Bookmark Manager</title>
</head>

<title>Dynamic Bookmark Manager</title>
</head>

<body>
<div id="root"/>
</body>

</html>
<body>
<div id="root" />
</body>
</html>
2 changes: 1 addition & 1 deletion src/shared/lib/bookmarkNodes/filterNodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function _filterBySearchText(nodes = [], searchText = "") {
}
return nodes.filter(node => {
const searchTextLower = searchText.toLowerCase();
if (node.title.toLowerCase().includes(searchTextLower)) {
if (node.title && node.title.toLowerCase().includes(searchTextLower)) {
return true;
}
if (node.url) {
Expand Down
2 changes: 1 addition & 1 deletion src/shared/lib/bookmarkNodes/getFilteredNodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function getFilteredNodes(nodes = [], { parentId, searchText }) {
});
}

function _isIncludedInTitleOrUrl(node, searchText) {
function _isIncludedInTitleOrUrl(node, searchText = "") {
const searchTextLower = searchText.toLowerCase();
if (node.title && node.title.toLowerCase().includes(searchTextLower)) {
return true;
Expand Down
12 changes: 10 additions & 2 deletions src/shared/lib/bookmarkNodes/getSortedNodes.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import { isFile, isOnlyOneFile } from "./comparisons";

function _safeToLowerCase(value = "", defaultValue = "") {
if (typeof value === "string") {
return value.toLowerCase();
} else {
return defaultValue;
}
}

export default function getSortedNodes(nodes = []) {
let sorted = [...nodes];
sorted.sort((lhs, rhs) => {
if (isOnlyOneFile(lhs, rhs)) {
return isFile(lhs) ? 1 : -1;
}
const lhsTitle = lhs.title.toLowerCase();
const rhsTitle = rhs.title.toLowerCase();
const lhsTitle = _safeToLowerCase(lhs.title);
const rhsTitle = _safeToLowerCase(rhs.title);
return lhsTitle.localeCompare(rhsTitle);
});
return sorted;
Expand Down

0 comments on commit 03ac118

Please sign in to comment.