Browse Source

Add a capability for the reference API and expose the regex to clients

Signed-off-by: Joas Schilling <coding@schilljs.com>
tags/v26.0.0beta1
Joas Schilling 1 year ago
parent
commit
d434da75bb
No account linked to committer's email address
2 changed files with 14 additions and 2 deletions
  1. 4
    1
      lib/private/OCS/CoreCapabilities.php
  2. 10
    1
      lib/public/IURLGenerator.php

+ 4
- 1
lib/private/OCS/CoreCapabilities.php View File



use OCP\Capabilities\ICapability; use OCP\Capabilities\ICapability;
use OCP\IConfig; use OCP\IConfig;
use OCP\IURLGenerator;


/** /**
* Class Capabilities * Class Capabilities
'core' => [ 'core' => [
'pollinterval' => $this->config->getSystemValue('pollinterval', 60), 'pollinterval' => $this->config->getSystemValue('pollinterval', 60),
'webdav-root' => $this->config->getSystemValue('webdav-root', 'remote.php/webdav'), 'webdav-root' => $this->config->getSystemValue('webdav-root', 'remote.php/webdav'),
]
'reference-api' => true,
'reference-regex' => IURLGenerator::URL_REGEX_NO_MODIFIERS,
],
]; ];
} }
} }

+ 10
- 1
lib/public/IURLGenerator.php View File

* *
* @since 25.0.0 * @since 25.0.0
*/ */
public const URL_REGEX = '/(\s|\n|^)(https?:\/\/)((?:[-A-Z0-9+_]+\.)+[-A-Z]+(?:\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*)(\s|\n|$)/mi';
public const URL_REGEX = '/' . self::URL_REGEX_NO_MODIFIERS . '/mi';

/**
* Regex for matching http(s) urls (without modifiers for client compatibility)
*
* This is a copy of the frontend regex in core/src/OCP/comments.js, make sure to adjust both when changing
*
* @since 25.0.0
*/
public const URL_REGEX_NO_MODIFIERS = '(\s|\n|^)(https?:\/\/)((?:[-A-Z0-9+_]+\.)+[-A-Z]+(?:\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*)(\s|\n|$)';


/** /**
* Returns the URL for a route * Returns the URL for a route

Loading…
Cancel
Save