Actualizacion maquina principal
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / remark-stringify / lib / util / enclose-uri.js
diff --git a/.config/coc/extensions/node_modules/coc-prettier/node_modules/remark-stringify/lib/util/enclose-uri.js b/.config/coc/extensions/node_modules/coc-prettier/node_modules/remark-stringify/lib/util/enclose-uri.js
new file mode 100644 (file)
index 0000000..9a53ae6
--- /dev/null
@@ -0,0 +1,24 @@
+'use strict';
+
+var count = require('ccount');
+
+module.exports = enclose;
+
+var re = /\s/;
+
+/* Wrap `url` in angle brackets when needed, or when
+ * forced.
+ * In links, images, and definitions, the URL part needs
+ * to be enclosed when it:
+ *
+ * - has a length of `0`;
+ * - contains white-space;
+ * - has more or less opening than closing parentheses.
+ */
+function enclose(uri, always) {
+  if (always || uri.length === 0 || re.test(uri) || count(uri, '(') !== count(uri, ')')) {
+    return '<' + uri + '>';
+  }
+
+  return uri;
+}