1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-12-01 02:27:17 +01:00

Inlined regex escaping from dependency

This commit is contained in:
squidfunk 2019-04-17 10:40:41 +02:00
parent 13a4c9172d
commit 185147684c
9 changed files with 242 additions and 1175 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -66,7 +66,7 @@
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block libs %} {% block libs %}
<script src="{{ 'assets/javascripts/modernizr.1f0bcf2b.js' | url }}"></script> <script src="{{ 'assets/javascripts/modernizr.74668098.js' | url }}"></script>
{% endblock %} {% endblock %}
{% block fonts %} {% block fonts %}
{% if font != false %} {% if font != false %}
@ -190,7 +190,7 @@
{% endblock %} {% endblock %}
</div> </div>
{% block scripts %} {% block scripts %}
<script src="{{ 'assets/javascripts/application.3ca04de7.js' | url }}"></script> <script src="{{ 'assets/javascripts/application.48c2c9de.js' | url }}"></script>
{% if lang.t("search.language") != "en" %} {% if lang.t("search.language") != "en" %}
{% set languages = lang.t("search.language").split(",") %} {% set languages = lang.t("search.language").split(",") %}
{% if languages | length and languages[0] != "" %} {% if languages | length and languages[0] != "" %}

1388
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -54,7 +54,6 @@
"cssmin": "^0.4.3", "cssmin": "^0.4.3",
"custom-event-polyfill": "^1.0.7", "custom-event-polyfill": "^1.0.7",
"customizr": "^1.2.1", "customizr": "^1.2.1",
"escape-string-regexp": "^1.0.5",
"eslint": "^5.16.0", "eslint": "^5.16.0",
"event-hooks-webpack-plugin": "^2.1.1", "event-hooks-webpack-plugin": "^2.1.1",
"expose-loader": "^0.7.4", "expose-loader": "^0.7.4",

View File

@ -20,13 +20,25 @@
* IN THE SOFTWARE. * IN THE SOFTWARE.
*/ */
import escape from "escape-string-regexp"
import lunr from "expose-loader?lunr!lunr" import lunr from "expose-loader?lunr!lunr"
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* Functions * Functions
* ------------------------------------------------------------------------- */ * ------------------------------------------------------------------------- */
/**
* Escape a regular expression string
*
* Taken from the package `escape-string-regexp`
*
* @param regex - Regular expresison string
*
* @return
*/
const escapeRegex = regex => {
return regex.replace(/[|\\{}()[\]^$+*?.-]/g, '\\$&');
};
/** /**
* Escape HTML strings * Escape HTML strings
* *
@ -291,7 +303,7 @@ export default class Result {
}, new Map) }, new Map)
/* Assemble regular expressions for matching */ /* Assemble regular expressions for matching */
const query = escape(this.value_.trim()).replace( const query = escapeRegex(this.value_.trim()).replace(
new RegExp(lunr.tokenizer.separator, "img"), "|") new RegExp(lunr.tokenizer.separator, "img"), "|")
const match = const match =
new RegExp(`(^|${lunr.tokenizer.separator})(${query})`, "img") new RegExp(`(^|${lunr.tokenizer.separator})(${query})`, "img")