FPRDataUtils.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2020 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import <Foundation/Foundation.h>
  15. /** Trims the given name string and checks if the name is reservable.
  16. *
  17. * @param name The name to be checked for reservability.
  18. * @return Reservable name or nil if there is an error.
  19. */
  20. FOUNDATION_EXTERN NSString *FPRReservableName(NSString *name);
  21. /** Trims the given name string and checks if the name is reservable.
  22. *
  23. * @param name The name to be checked for reservability for an attribute name.
  24. * @return Reservable name or nil if there is an error.
  25. */
  26. FOUNDATION_EXTERN NSString *FPRReservableAttributeName(NSString *name);
  27. /** Checks if the given attribute value follows length restrictions.
  28. *
  29. * @param value The value to be checked.
  30. * @return Valid value or nil if that does not adhere to length restrictions.
  31. */
  32. FOUNDATION_EXTERN NSString *FPRValidatedAttributeValue(NSString *value);
  33. /** Truncates the URL string if the length of the URL going beyond the defined limit. The truncation
  34. * will happen upto the end of a complete query sub path whose length is less than limit.
  35. * For example: If the URL is abc.com/one/two/three/four and if the URL max length is 20, trimmed
  36. * URL will be to abc.com/one/two and not abc.com/one/two/thre (three is incomplete).
  37. * If the domain name goes beyond 2000 characters (which is unlikely), that might result in an
  38. * empty string being returned.
  39. *
  40. * @param URLString A URL string.
  41. * @return The unchanged url string or a truncated version if the length goes beyond the limit.
  42. */
  43. FOUNDATION_EXTERN NSString *FPRTruncatedURLString(NSString *URLString);